NOWCommunity Live Stream - Lessons Learned - Flow Designer Tips 1
[Music] good morning good afternoon good evening wherever you are and whenever you are welcome to the community live stream this is the show that helps take a look behind the answers on the community inspired by your questions and inquiries and problems that you post on the community and I take those and turn them into a topic and in this case I'm taking all but two lessons that I learned about flow designer Who am I well my name is the title sorry I gotten to keep ad over the weekend so I'm learning where the new layouts are for all of these titles and what not so my name is Chuck Tomasi I'm a senior developer evangelist at ServiceNow been here for about ten years customer for a couple of before that so go way back into the dinosaur eras in service now and that's where I got my start in late 2008 so happy to be here happy that you're here and looking forward to sharing some of my tips on flow designer that's what I've been doing for the last several weeks converting a lot of legacy script into flows and discovering some things along the way that aren't necessarily documented but still very valuable and this is my way of sharing that with you so that you can take those tips and tricks and journey of discovery and be a more effective ServiceNow administrator and developer that's what the show is all about if you're watching this on YouTube thank you very much don't forget typical YouTube stuff click the like button subscribe notifications you know what to do there it's all at the URL you see there on the bottom of the screen we also do this as twitch in the background good morning to everybody who's joining me wow they're jumping on the livestream like crazy Ellen and Ria's and Dhruv say car thank you very much for joining it warms my heart to get up in the morning and be able to share this with you this is you are the reason I am here this is the if you didn't watch and you didn't use ServiceNow there'd be no point me to go eight minutes so I feel very honored and very privileged to be able to do that so twitch is also a backup invite you to go over to the developer portal if you have done so already get yourself a free personal developer instance you can learn more about flow designer and building flows and integration hub without any risk to your organization this is your private sandbox if you wish to invite friends you can do that but this is I recommend everybody get their own that way you can streamline the change management say you know what this instance needs to be easy booted which is what we call resetting it back to factory defaults and you can z boot it anytime you want there is learning plans there's documentation there's blog articles there's all kinds of great stuff that you can get over at the developer portal if you haven't done so already one of the things you can get obviously is information about meetups which I have another screen here still doing the screen layout here get the where to go meetup title over at meetup.com slash pro slash ServiceNow dev program I know that's a bit of a mouthful but join that and you will get notifications look for areas look for chapters in your area if there isn't one you could start one I know this was really designed around the time when we can get together in person face to face but it still works very very well virtually I am NOT able to attend more of them there is one going to be held in Pittsburgh Pennsylvania later this week that I'm very much looking forward to there are others I think we had Vancouver a couple of weeks ago so I'm able to do this without hopping on a plane we can go to various chapters some are talking very in-depth developer scripty stuff and others are saying hey I want to talk about surveys doesn't matter this is your chapter these are your people this is oh time to get together and discuss things not so much like a ServiceNow user group or a snug but developer talk we help support the content you pick the date we used to say pick the venue but the venue is even easier now you don't have to pick a venue you don't have to go scouting around do we get a room at the library do we get you could do this all from your home it's even easier now so join the community join the meetups and be part of that and you can even start scouting around before another chapter I know drew had a wonderful meetup yesterday was it part of the meetup program but it was a nice meetup that we had I got up bright and early at 6:30 on Sunday morning because it was at 7 p.m. ist and wonderful discussion all about resources for learning to be go from Edmond to developer if you're new to the platform we really ranged on a lot of things thank you very much for that content and I believe you recorded that and posted it as well so if you missed it you can always go back and watch a couple hours worth of presentation and good Q&A really good Q&A on that as well thank you everybody for joining let's get on with some of the other stuff we won't be doing much javascript in here I think there's a little I got to remember what I put together for notes I'm looking at them now but if there is any script you can always find this excuse me you can always learn more about javascript by going to the URL here bitly /sm - learned SJS that link came up more than once in yesterday's Meetup so got some good reception on that people are giving very positive feedback if you want to learn JavaScript not just hey I want to learn JavaScript you can do that on udemy you can do that on code Academy you can do that w3schools this gives you the service now intricacies about doing that if I do write any code today it will be available on the github repo that you see there yes a CLS and if you're just really getting started or you're you want to dig more into flow designer take a look at the e-book I know there are hard copies floating around out there somewhere well the green almost disappears onto the screen the letters sort of fall off ooh you can see through the book no code apps for dummies is available out there they agree now the book must be the safe colors the green screen behind me okay that being said let's get started with what we're going to talk about today we have flow designer and I want to talk about see if I can get all six of these in I can't make any promises that's why it says flow designer tips 1 I am going to be learning more and if I can't get everything in today I will definitely be extending this out in the upcoming days and week so look forward to that good morning so while the good mornings are still rolling in thank you very much for joining this is puts a big smile on my face it makes this even more fun number one that I learned was a while ago one of my colleagues in Germany showed me I don't know why I didn't see it it might be one of those mental processes where once you start doing something you just sort of stick with it because it works so I have a table here of courses we talked about this a few weeks ago where I've got projects and programs and courses and tasks said just a hierarchical table when I was showing you cascade delete rules so this is a course record and it has on it an approval field let me zoom in on that a little bit approval is a choice field and it is linked to the choices on the SIS approval underscore approver table there is a choice of is this requested is it not requested as it approved isn't rejected you get the idea rather than copying all of those onto my tables choice list I linked to them and I think I've shown you that before so if I go to configure dictionary will zoom back out go to the dictionary entry for that real quick reviewer refresher on how to do that underneath you have to turn on the advanced view so down here if it's not on click advanced view down in this corner it is already on and my dependent field excuse me my choice list specification says go to this table and get the choices from this other field very handy if you have a lot of common choices it's done but some people instead of using checkboxes for true/false fields they use yes/no as a choice field that's fine but you don't have to put in choices every time saying yes no yes no yes no yes no yes no you can point them all to a common yes/no parent and then maintain them that way much easier so that is my approval field the reason I have that is because this table is not extended from task if it were extended from task I would have an approval field already for me but I did not this was a discrete table and as a result why does I feel like 150 percent I'm gonna know that's 125 okay as a result something is zoomed in a little crazy I don't know exactly what's going on here they're my zooming thing got a little out of control as a result I don't have an approval field so I made one and linked it back to that other one so I have a common set of states on that approval now what I would like to do is just set up a simple approval for this inflow designer or say look when a course gets to the state and I have a state field over here where approval is required very common thing you might do with incidents or changes or whatever you got for your process you might need to get an approval so I brought up flow designer flow designer is our flow at work flow tool workbench whatever you want to call it that we introduced in Kingston that's like two and a half years ago I think well it's been a while at least eighteen months ago if I count the releases yeah that's a while ago because we're now on Orlando Kingston London Madrid you get the idea the let me get the flow for the course approval up here and you can see if you're familiar with the older work flow it works a considerably different than the old work flow this is more like a super business rule or schedule job that you can create here is a trigger at the top I'm going to trigger this whenever the course is updated and the state changes to approval you can see that all right there nothing magic happening and run only if it's not currently running there's a number of choices in here I may want to run it once and only once and be done with it with approval as you often find that if it's rejected you want to go back Andreea prove it well the important part is not in the trigger it's this ask for approval and I got that by going to the big plus going to action and ask for approval is right there configure it it says what table so I said course the approval field very handy if you fill this in its self maintaining you don't have to go down here into the state fields after an approval or rejection it said it it's already maintaining itself because I linked it back to the same values on the SIS approval excuse me assist approval yeah this approval underscore approver table that's where all of the provers are stacked up know whenever somebody says show me my approvals it comes from that table I hard-coded it to say I am the approver but here's the thing that I was doing originally look here it says rules approve when anyone approves and it could be a data pill it could be a hard-coded group or a user whatever that entity needs to approve it I didn't even notice that there were other choices in here that said approve reject or the final one approve or reject call me blind call me just creature of habit some of you may have done this also you may not have seen this but this allows me to do both at once so if I pick that this changed to anyone approves or rejects now it's not you know this lightning crazy wow that's a mind changer it's just one of those things that I didn't see and I thought I'd pass it on to you so when I'm done that now my flow logic can say if approval state drag that overreach so this is pretty easy to build this stuff is approved then I'm going to go down this branch else if approval state is rejected you build practically as fast as you could say it this one I'm just going to put on a log I'm not going to change the state of the record or anything so we'll just do a log and say thank you for your approval thank you for your approval or this one will say it's been rejected and of course we could also put in else because we have an if and else if for programmers is a pretty simple logic for non-programmers it's not too hard to figure out okay sorry it was rejected it was a problem with keyboard this morning rejected and we'll also put in an else just to close this whole thing out as a default case another log might be handy it was something else it was something else hey not the best blog but you get the idea of how you can take this one approval and do multiple things at once you don't have to have well was it approved if it not then you could only do an if-else on that really because I will just go on let me do a quick save on that I will save your work save early save often and give a test going to test it on course record oh I don't know this one when you do a test just as a quick reminder eight skips the trigger so I don't have to wait for the trigger condition to happen I'm not updating the record if I was doing an update record action then would be updating the record so let's click the execution details and you can see here it is waiting for the approval which means if I go over to my favorites I think I have the approvals list in here I should be at the top here yep state is requested and I hit approve don't worry about the right operation thing that's kind of bogus in this case refresh on this give it a second sometimes the execution details are even driven and need a second here we go evaluated to true did the log I can see in the log that says thank you for your approval the rest of the scuff stuff was skipped just never and didn't need to because it was evaluated as false so approvals have that choice in the rules to say approve or deny or approve or reject easy as that that was that was the first one okay that one I didn't spend a whole lot of time figuring out somebody showed it to me some of these cost me an afternoon of going what is going on and why is this so somebody did ask this in Oh what was it it was a meet-up or something recently I remember it was asked verbally no is in the middle of tech now that's what it was we Michael slobotnik on the 23rd of June if you haven't watched Tech now so do 76 I invite you to watch that a lot of good information about flow designer and integration hub in the past three releases so Madrid New York Orlando a lot of great stuff more coming out I've got an episode coming out at the end of the month I'll have that sort of that that splash screen that we go through at the intro soon so about Paris so Paris features if you're not a developer get sign up for the developer program that's one of the benefits you get is a notification to be part of the early access on your PDI and you also get to see the tech now before everybody else because if you miss it there you gotta wait until we do our market launch with all the other announced and you kind of miss out so don't miss out sign up for that that was my quick plug okay one of the questions that came up and there was hey when I do a lookup record and it doesn't find the record my flow stops so let me stop here and find this real quick it was called maybe I don't have one in here already you do do do do let's just show matching on my flows for this app get all courses no I don't think I made one for this one did I I'm checking my notes real quick just to see if it was there nevermind that will create one so let's create a flow and we call this look of course just because it's simple and I'm not feeling very imaginative I am going to doesn't matter what the I'm just doing this as a test so I'm going to just say it run this once today a 3 a.m. is fine because it's not going to do the trigger I'm just going to test it you can run this on email coming into the system those are fun now if I do a lookup record and I say action look up record I say just go get a specific record from the course table and I say my filter condition is name starts with CS if you look at my course table I'll go back here to my history there's my courses I have a CS 210 and I run that and just below it I will put a log de course named action log course name boom yeah pretty easy just to say yep I ran it and I test that well first I'll save it then I'll test it lookup record is is basically the flow designer way to do a glide record query it's a query to say go get me this record and when it works it works well so we run the test and time passes click that and it says I completed your lookup record and I log your message and I print your course name so you think well that's wonderful that's great but then the condition changes or the data changes and I say starts with tr I'll start with something a little more obscure Q X and I save that and test it and when it doesn't run it doesn't run it errors out I wish it had a fault condition in here be nice if we did I run the test and you'll see boom no record found therefore you get no log message all logic after that is done it will not run this flow has effectively erred because you said go get this specific record hey well this is no fun so I said what else do we have in the toolbox because I do want to continue if I don't find that record so the simple solution is get rid of look of records record and go for lookup records a plural gives you the same kind of option where you say course table conditions name starts with Q X and note down here maximum results hey maximum results I'm just gonna put one I only need one so why go query a bunch of things I just want that one record that I know I'm after it could be bye sis ID it could be by name it could be by unique record identifier who knows who cares now if I undo mout of that notice also over here I have the course records that it found this is an array of objects that it will come back and tell me the table it was querying and how many records it got this is your flag to say did it work or did it not so you can do your own error trapping in here to say if count is greater than zero okay or you could say if count is zero and throw an error do whatever you want let's take my log message and move it up there I can drag and drop these things around very handy and we will put the Oh can't log it yet because it's an array of objects what you must do at this point is put in before each logic to iterate over that array of one thing okay it sounds silly but it's true you have to do this because this is a series of records and I am going to once again move this over here so my log statement I've now got some nesting going on and this can get a little deeper than you may have originally planned but it's bulletproof if my data changes and there's no records it won't crash it will just not follow that path so if I say give me the course record name and I say put that there I missed drag and drop we're having a wonderful day on the keyboard if this is my for each let's also put in an else here that can log us a quick message that says hey you know what I didn't find any records no records found sadface no it's gonna see that in my log anyway save that and my condition still says I'm looking for things that start with Q X so it will fail it better fail but I set it up to do look at the execution details and sure enough it got down here to the else my log says no record found sad face if I change the condition however and I do pass look up records starts with CS save and test always takes a little longer this is where I usually get a drink of water dehydrated execution details this time Oh said false what happened did I miss something did I miss something name is CS Noah let's do starts with I missed it starts with CS believe it can be lowercase as well searches are typically case insensitive but I haven't done it I haven't tested that inflow yet so we're now testing it alright this time it did evaluate to true and it got down here and iterated over my one record and said hooray your record that I found all one of them is CS 210 so I've got this way of branching a path to say if I found records go this way if I didn't find records go that way as opposed to look up record that just says go try it if it didn't work it's gonna error so I find this to be a little more robust and it wasn't the most fun thing to discover I had this complex flow and when it got to a lookup record which I swear was there but as often happens it may be there in dev but then you migrate all of your changes over to prod you didn't bring the demo data or the test data or the the code you need in a table over and uh yeah it happened it happened to me on Saturday okay Oh rats I forgot to give this table so you know you go back into an export XML import XML get your data over from sub prod to prod and away you go but in the meantime your flow or whatever is not having a fun time alright so that's number two about looking up a record person look up record versus look up records number three seeing more output I do a lot of integrations now I'll do even more with integration hub and I wanted to see what was coming back in the payload but after a certain point it got chopped off it's like the format completely changed I mean whoa hey let me give you a quick example here's my flows here's my serialized output test and ah there's nothing in there let me see if I can get this oh test the other flow wrong flow I want look up the videos I don't remember making that one maybe I didn't save that one look up something nope maybe wonder look of course and I named it wrong no that was the one that I just created okay we're gonna start from scratch I thought I had a little bit of this set up let's go and create this I may have may have a oh never mind it's a it's an action it's not a flow pardon me so there's my simple array let me go to you can test actions now by the way it's very handy so typical thing that I would often do as I make these videos I like to keep tabs on them in YouTube so I go in look up videos and what you can do is instead of looking up a video by specific ID you can send it a whole list of comma separated values and it will look up up to 50 at a time and went great that's wonderful however when I test this and say here's a holster of ID's and unfortunately I don't have this in my macro editor somewhere I'm going to have to go get it pardon me I forgot to prepare one step on this thing I am going to fastest way to get this probably from Evernote that's where it's stored a bit of a sidetrack here oh yeah to Evernote this isn't signing me up sign-in yeah I think that's the right one go with that and two-factor kids if you're not doing to factor you should I keep them all on my watch Evernote I just need a big long string of information out of these notes apologize for the little sidebar uh if why do we have lookup record because they're going to be records that you know will always be there like the property instance underscore name if that's gone you have more serious problems and then just your flow crashing okay if you've got 100% certainty confidence that lookup record will always be there you can do it as we wait for Evernote we'll have another little conversation looking through the questions a lot of good morning good morning good morning everybody thank you again for joining I just need a really long list of video IDs and I apologize I forgot to set this up beforehand so as we watch Evernote status bar go we will go to my my voicemail message community livestream outline come on there it is down here is prove there's what we're gonna cover that's what we just need cover and use these womp get those okay back to my other browser window Thank You flow designer paste just a bunch of comma separated values that I'm throwing at you too saying tell me what did you find and it will run up to 20 of these in the test even though I gave them 50 and I notice that that's not exactly a readable output I was expecting a nice JSON thing that said here's your list of 20 things that you asked for and returned them it did not you know what is going on because if I shorten that up to oh let's make it something less significant like what is that about 10 run that test what I would expect is and I played around with this I went can I do three can I do for can I do five it stopped at five what's going on let's open the data stream action and nope nope nope it was uh you know was it still craziness mm-hmm let's just try three of them this is exactly what I was doing like a week ago saying what is going on here why am I not seeing my nice formatted JSON output like oh I didn't want to open the action I mean we already saw what that was I want to open the log there that's what I expect to see and you can see some of these are kind of long oh man there's there's a lot of loud or blocked regions in this video so as I built my integration I was expecting in I'd add another element and then suddenly it stopped working what's going on turns out there is a property for that like many other things the idea is if it gets too big we don't want to be wasting a whole lot of memory and time with that and the property name is insist properties sis underscore properties list is where you find a lot of this stuff it is called where to go comm dot SN C dot process under flow got reporting dot serialized uh-huh it is documented Pal size limit there it is if you look for flow designer properties you'll find this it's actually I think it's in the properties page let's the go check okay flow designer under flow designer there his properties and and I said it to specify the level of diagnosis the maximum amount of iterations no maximum number of records returned no okay well that wasn't it when the serializing operation because I've got might set to 4,000 it is in the global app so let's go we'll run over to global real quick change that to it defaults to 1 6 3 8 4 and for those of you who know your base 2 numbers that is 4000 hex now if you need it bigger you can make it bigger for example double it 3 to 7 6 8 would be 8000 hex going way back into the 80s for these numbers and let's try the test again with my big bad list of video IDs and watch what happens I've said you know what you can show me more than 4 K of characters you can show me a lot more and when I do that when I click the right thing execution details video stream I now have my output patterns with all 0 through 19 which is 20 records showing me what I want simple property show more so if you run into the case where your actions are not showing the right thing doesn't necessarily mean it's working with it it's not an integration hub thing specifically you could be creating a complex object an array of objects at array of strings and it just gets too big to show if you start seeing the output go a little weird when you're looking at the execution details check that property well it's again it's documented I'll have it in the links in the show notes so don't worry about memorizing that big ugly thing what's the formatted tab then so the formatted tab when I went down here and so this format it is if it can format it in a in a nice way it's already Jason the raw text is already formatted so that's not gonna get to anything I believe that was with XML I got a check it sometimes it does some things and I haven't figured out what the exact use case is there I'm sure somebody with more flow designer acumen than me can give you that answer let's move on to number four we are cruising through these and we're doing great on time duration fields ok familiar with the duration field I am because I like to get durations on my videos so duration fields think I have put yeah put one on the course table what I wanted to do again going to my YouTube example is go to YouTube and YouTube has a duration on the videos it's in a crazy format I think it's ISO 8509 or something it says PT three m24s which means three minutes 24 seconds I've written a script include function to change that into a glide date/time you get the idea well what I wanted to do was say here is my course table here is my duration field and you can see if I do show duration it is a glide duration so I merrily went too long and built an action to convert the duration and then save the duration so let's go back to flow designer and look at the notes run the sub flow course duration so let's go to sub flows do you do do you did you do did I change my scope back I did not this would probably be nice although it's not as critical in flow designer because each flow has its own flow flow its own application so matching and update duration I have a sub flow and I pass it a course record sub flows are very handy we've talked about them before yet duration is my custom action and it says what would you like to doom well this one is actually hard-coded to two minutes I will show you there's no great secret about this and then after I get the duration I have a data pill here of type duration see this duration duration everything's making sense because it's a duration field or so I thought you know this is going for a twist right in the action this is a duration this is a duration in the action pop that out in in my real action I was getting the YouTube variable turning it into a duration field and then saying here pass this back it's a nice day and all this fun stuff hey see this code pretty straightforward I set a glide duration class type variable and then I pass it back and my output variables are duration duration and everything's cool and passing it out of the script I'm passing it through the it outputs through the action passing it out as a duration and you would think life is good when I test it it's hard coded of course - two minutes I wish I had a course that was two minutes you go hey looks like things are running right the action saying it's two minutes you're waiting for it aren't you where's the problem Chuck the problem is on this guy who says duration is going to use the duration out of here and when I test this on my CS 210 course and I wait and it says yep I ran and yep the value put in the duration field was two minutes and I go check the record and it says nothing was updated did you do it or not you said you did what's going on reload the form try it nope this should have a 2 in it a zero to be more precise why isn't this working what is wrong with our duration fields well here's here's the crazy part it's not really a duration field the action should not and I think Goran ran into this like a week before or I did which was kind of funny because he said yeah it's like the the internal person pointed me at gore and slack thread but here this might help okay so I'm not the only one change a couple of things one this should not return a glide duration object it needs to return a string and the string is formatted in one of those duration values okay just like you see the input here I'm gonna blow that up so you can see it it's day hours minutes seconds and I am going to still set it that way but I'm going to add a couple of things in here because there's two different things happening day value is going to be the GD yet day part that's a method from glide duration that gets me the 0 1 2 3 now I hard-coded this to 2 minutes so it's better return a 0 and the other part is GD dot yet nope I'm sorry this is did that backwards this is get day part named my variables poorly not to get day party that would be way too much fun this is get duration value that's what gets the hours minutes seconds why get duration value doesn't return the day part I don't know but I've had to stick these two together and for whatever reason if you just get the duration value and you try and stick this you're gonna see some weird things with that day value this is maybe another flow thing because I only see it in flow when I'm analyzing excuse me the output pieces it was saying like negative ten thousand four hundred and thirteen days and two minutes okay okay that's when I said I'm gonna forcibly get the day part on you and it's always going to be right so this then becomes day part plus space plus a duration value return that as a string so change this to a string which is also going to kind of mess up the script outputs here this is still a duration but I can't drag the value on there so let's edit outputs change that to a string confirm that it is changing put the script we'll get it exit edit mode and put that there now everybody's talking string to string a string except for the sub float now I do need to publish that because the sub flow wants to know about it and it says all right I'm getting your duration now look over here duration is now a string and what do you want to do with the course record well I am going to set the duration field let's take that out just because I don't trust it but I can set duration with the data pill picker to the value of get duration still using the data pill still going to work how a string fits into a duration field I don't know because normally you can't MIT you can't mix and match these data types like putting a reference field onto a choice list it'll say no no it's not the right data type but this one does work I test it run it please provide a value for course well apparently I didn't oh I'm not even looking at what I'm doing here test oh this was another odd thing that I found out see how it says CS 210 you try running it it goes no give me a different course you just clear it out and pick the same thing I don't know why it does that on consecutive tests so now look what it says for the duration down here it's in the duration string time format much different than just saying two minutes that's like the display value right okay that doesn't work and it doesn't work to map it in think about when you're doing like a reference field a display value versus the value value of the sis ID they're two different things duration fields kind of work like that only we have to set this value this is the value of the duration field and if I go over here hurray victory we've got two minutes of worth worth of this so yeah that was an afternoon of fun and I condensed it into about seven minutes for you you're welcome let's let's go to number five I've got six of these so number five is empty lists failing in a for each now I showed you earlier how you can do a lookup records and if it returns nothing we can still get the count my recommendation is always put a count if you're returning an array of objects in my case I was returning an array of strings let's go back to flow designer and my notes say I want to run the flow sample array test so let's open up the flow sample Sam o array test and again I pre-built some of this to save you the agony and pain of watching me do this this is an action I call sample array and I have a checkbox down there says return 0 length or return something it's either give me something or nothing just to show that this case is true if you want to dig into the action let's take a look at that it's a very very simple thing it says hey here's an array of something but if they check the box I'll send that I'll return a non-trivial list otherwise I'm going to return an empty list now my output variables for the script are an array of strings and each string has an item so I've listed item not very cleverly named but you get the idea my case I was returning an array of strings and my for each was dying when it had no results which is because perfectly possible because this array was generated from a lookup a glide record query and the flag record query came up with nothing fine but I don't want my flow to die if nothing happens kind of gets back to the same lookup record versus lookup records but now I'm in control of this array of objects doesn't happen for lookup records we saw them when the list was 0 it still said all I'm returning is the list and my outputs and the list and I'll show you what happens if you test it and go you know return a nonzero length always test your actions before you put them on flows or sub flows it goes here's your answer same thing we saw before with a nice JSON format it goes there's nothing in it okay that's lovely but in my sub flow my for each is going to run along that list and then log them out and right now I have this set to return a non zero length how we could have labeled that something a little differently if I test this it's going to return the list of 1 2 3 4 5 6 7 8 and it will create log statements to that effect and you can see down here it ran 10 times and my log says look at these it says item 0 is 0 1 2 3 4 5 ok when there is content there it works fine but when there is thought it's not so much fun let's back that up I'm gonna close some of these execution details that we had before or get a few too many tabs running around here let's run it again simple array test and this time say return nothing done test run and it runs and it says error on a for each how does a for each die this makes no sense those well I had nothing to do so I'm not gonna do it ok how do we get around this one well as I stated earlier put a count in and then when you come out of your creation of this array of objects of strings of integers of whatever you know how many you got you're in charge of making this action so you might as well return a little extra information to be kind to yourself in the flow and be kind of the flow at the same time let's go into that action and the way I would do that is create a new output variable in the script called count make it an integer because it's going to be treated as one and in here let's do outputs dot count I hate it when it does that equals outputs that list dot length okay that sets the list length now the script knows what to do with it now the action needs to play along to create a new output same kind of thing here so we're going to pass count the integer count from the count that comes out of the script can't do that yet we have to exit edit mode then drop the data pill into there save it publish and now our action has a little more improved output so before we launch into a flow that are for each that's going to die let's first do a condition that says if just like before nope we need to refresh we need to save first so that it gets the new action it's there now count shows up okay if count is not zero then I can do my for each up here just make sure that it's still working it's pulling from the list yeah that looks good anytime I move something I always check the data pills cuz sometimes their references can get a little wonky depending on what you doing if you're deleting things above it it may delete the references in there just go walk down the tree again and make sure things are right 2.1 is an item it's going to log that and let's also put an else in here just like before else log no records found let's do it log come on log probably just type it faster at this point log scroll up so you can see that no records found or no items found or no list empty list whatever you want to put in there save that test it again total run the test and this time it did not crash it went down my else because I have count to save myself from myself it's so that the array doesn't crash why it does this I don't know it seems like the for each to just go yeah it doesn't but in the interest of fostering better programming skills you should always be doing some data checking right and you may want to check the case where it's a zero or a non zero so do yourself a little favor when you're building outputs that are lists of stuff include a count of what that list is so that you can check it in the flow and take appropriate actions there that's number five we have just enough time I think for number six all right I mentioned earlier that you can do a number of triggers in flow designer including emails and I recently converted an inbound action into a flow because you can trigger there's my sample email I am totally on the wrong screen because I'm moving the wrong mouse okay sample email one of the triggers up here you can see we've we've often done created updated scheduled you saw me do a run once but down here is inbound email these run before the scripted email actions let's say this once when there is a script list solution available on the platform take it hey you've got the choice about writing script in an inbound email action you've got a choice about running a flow or writing a flow write the flow trust me on this if you've got a choice between running a writing a scheduled job in script or writing a scheduled job in flow write it in flow even if you have to make a couple of custom actions which are probably going to be this much code for an action and that becomes a reusable component write it in flow stop writing schedule jobs unless you absolutely think you have to you know you have to stop writing inbound email actions go ahead and maintain the old ones that are there but create new ones in flow same thing with the legacy workflow maintain what you've got there but create new flows in flow I'm gonna make a new t-shirt that says go with the flow all right so this is the trigger inbound email it doesn't have any special creators on that and I'm going to create a to do record now one of the things I want in my record is to process the HTML body over on the right hand side you can see I've got access to my email record and they've surfaced a number of these common data pills up to the top level here's body text and subject there is a body text and subject underneath the email record and I could get them this way what I found a little confusing was in my script we have inline scripting now so flows and actions are much more flexible you turn it on turn it off down in here is how you access those variables the data pills through script there is this F D data object and as you start to type you can get it this is how I would get the body of that and I got that simply by going to FD look whoo intellisense type-ahead dot trigger as you get more data pills you'll get more choices and then I wait all right so we've got the from address we've got the subject target record got the body text a lot of it looks like that top-level stuff but I had to drill into inbound mail then I hit dot and went oh here we go now if you've done inbound email actions via script you know that there's two elements for the body there's body underscore text and there's body underscore HTML I discovered this because I was trying to process body and going where's all my stuff it's a skinny down version I was forwarding something from Gmail that had a lot of HTML including a couple of links and they needed to parse those links wasn't happening with body underscore text that's sort of the default that everybody uses body underscore HTML gives you all of the CSS and everything else it's a much fuller message notice on this pick list slightly behind my head apologies about that I'm gonna raise that up a little bit you can't find a body underscore HTML it simply referred to as body so I am going to put in the description for my new to do the email body which is going to be a lot of HTML but that's okay an example don't click the FX button that turns it off like this little up arrow to collapse it and it will say the value is coming out of the script now what I was doing was passing that FD under data under trigger and about to a script include function to go through a process that then stick it in the field where I wanted it that's what I was after or actually return is a data pill let's go and test this so I have on my to do table a number of two dues waiting for the two dues maybe I missed and here are three of them not much detail in there and if I look into any one of them I have a nice big text description field let's go test the flow and I test it on where is it I'm gonna find it it was there it is just uploaded a video and I have some links in here but I'm just gonna dump the text in here look at the execution details array my trigger completed cuz I skipped it and the create record completed if I look at the output for the description field look I got all the HTML so it was just one of those confusing things when I was navigating through the data pills recognizing some of the data pills are at the top level the common ones body text subject from address you can get those without going into the inbound underscore email object you can just get it from the trigger data just like any other trigger data that you get from the inline script if you want the HTML however you're going to have to go into the record that's that was the quick lesson that I learned out of doing that so there's six important tips that I have for you on flow designer who that was a whirlwind wasn't it thank you for joining me say car let's go with the flow alright we'll make t-shirts or something some of my Etsy in summary I'm going to continue to learn things in fact I think I've already got my first tip on part two of this I don't know when that will come out when I get to about five or six will go I know this was a little longer than I've been doing these previous shows but I hope you found something valuable if you did don't forget to click the like the helpful in the community that kind of thing let other people know that it's there if you've got questions please post them in the community we've got the wonderful wonderful community with hundreds of thousands of people participating and it is the most vibrant the most active and the most intelligent community I've participated in over thirty years of doing online communities and forums so this is a very special place and I hope you take advantage of that until next time and next time is where's my notes it was hiding around here somewhere next time is not that note Oh where'd it go I had it it ran away it ran away next time is Thursday and Thursday is I should have it right here we're gonna be do a topical deep dive on Oh base on another one of John Feist's questions on the forum layout and I also included the list lad what does the data model look like behind that on views and forms and sections and fields that are on the forum he came out of a question that he asked how can a client's grip tell what fields are on the forum and I said well okay let's go into the data model and as I started outlining that last week it dawned on me that there's more to it when you start talking about views you get into lists and related lists said I'm going to cover all of that so you understand it and you can use that when you have your own questions about is this on the forum is this mandatory what kind of things I so the whole list and form data model is our lesson for Thursday join me 2:00 p.m. UTC whatever that is in your time zone and I very very much look forward to seeing you there and with that I think it's time to play the magic music and we're out of here thanks bye take care [Music]
https://www.youtube.com/watch?v=8ocmrYujQSE