I have a scenario that takes 3 typeahead fields and parses them into an array where I then add them as assignees on a created task. The three typeahead fields are:
DE: D2D Account Lead - Creative.
DE: D2D Account Lead - Digital.
DE:HCG EG Strategic Steward.
If the company I'm pulling from has all 3 filled out, everything works fine. If there are any blank fields I get a "Source is not valid JSON." error. I don't know what kind of error handling I can use to go ahead and create the array with only 2 entries. Screenshots below.
I could just add a service account to all un-staffed typeahead fields but that's a hack. Is there a right way to handle this error?
Solved! Go to Solution.
Views
Replies
Total Likes
Well, here it is. It's big, it's messy but it works. Setup dialog is on top, result dialog is below. I can't help but think there's a better way with less steps but for now, it works.
Hey Randy - I don't know that it's any better than the hack you describe, but the idea I keep coming back to is to build it out with different branches (or maybe an array) that then is used to build the resulting JSON. I think that will allow it to be built with just the relevant 1 or 2 responses.
From an error handler approach, would putting a router as the first time in the error handler to branch off based on what fields have a value and then rebuild work?
Thanks Jason, I figured it out and it looks messy and repetitive but no one will see the scenario but me anyway. At least it works!
I'm documenting it today so I'll post the breakdown of how it works so maybe others can benefit (or maybe even critique it and help find some efficiencies).
Views
Replies
Total Likes
Well, here it is. It's big, it's messy but it works. Setup dialog is on top, result dialog is below. I can't help but think there's a better way with less steps but for now, it works.
@RandyRoberts - is there a special tool you used to pull the above view together, or is it a bunch of copy and paste screenshots? I really like it for some of the documentation we need.
Views
Replies
Total Likes
Oh man, I wish. It's just a bunch of copy and paste brought over into InDesign for layout.
Views
Replies
Total Likes
Randy,
I know I'm a little late to the game on this one, but how I usually handle something this is IF({Property 1}!={null},{Property 1},;{empty string}. So then in the JSON string you would just have that 3 times, or however many properties you need.
Actually, I just thought of an easier way, since you're building it as an array. Create a variable (Not necessary, but it will make it easier to see what it's doing), and in that variable, add in {{add(emptyarray; {3.DE:D2D Account Lead - Creative};{3.DE:D2D Account Lead - Digital};{3.DE:HCG EG Strategic Steward})}}. Now, if it still adds null values as empties, you can add the command remove({array from previous};empty string)
Thanks Chris, I'm gonna try some other stuff to make it more efficient (and maybe learn something in the process). I'll definitely try out that idea.
Views
Replies
Total Likes
Views
Likes
Replies