January 16, 200719 yr Hi All, I've written a script that checks if a related record (R/R) exists for the current record using the find process. If a R/R exists the script automatically goes to it, if no R/R exists (error code 401) the script asks if one should be generated. I would like to use the GTRR script step rather than a find but I can't find an error code to match no R/Rs found in this case? Thanks Peter :-) Edited January 16, 200719 yr by Guest
January 16, 200719 yr Try using the isValid script step. If [ IsValid(Graphic link|::Container) ] Go to Related Record [ Graphic link| ] Else Show Message [ Buttons: “OK”, “Cancel”, “”; Data: “No Related Record exist.” ] End If HTH Lee
January 16, 200719 yr Author Hi Lee, I'll give it a try, I was hoping there might be an error code for no R/R found but maybe there isn't. Thanks Peter :-) Edited January 16, 200719 yr by Guest
January 16, 200719 yr You could also just use Set Variable[$layoutName ; Get(LayoutName)] Go To Related Record[GraphicLink] If[ $layoutName = Get(LayoutName)] #Create the record Else Go To Related Records [ You know this bit ] End If --If there aren't any related records you remain on the same layout. or use isEmpty on the primary key field in the related table. If[ IsEmpty( RelatedTable::PrimaryKeyField )] #Create the record Else Go To Related Records [ You know this bit ] End If This one may or may not also work: 415 One or more required related records are not available Edited January 16, 200719 yr by Guest
January 16, 200719 yr You can also set error capture on, try to go to related record and read the last error state. That is Set Error Capture[ On ] Go To Related Record[ ] Set Variable[ $$error, Get( LastError ) ] Set Error Capture[ Off ] I don't remember the error code exactly, but it certainly exists.
January 16, 200719 yr 101 - Record is missing But it seems neater to do the test beforehand and branch accordingly: If [ not IsEmpty ( Child::ParentID ) ] Go To Related Record [ Child ] # Do the stuff Else # Do something else End If [ ]
January 16, 200719 yr Author Thanks to everyone for their ideas, I'll experiment with the ideas later on when it's less than 35 degrees Celsius :-) My script currently checks if a R/R exists first then branches from there, it's just using the find record step, etc. was a bit messy so I was hoping this could be accomplished in less steps. Cheers Peter :-)
Create an account or sign in to comment