July 17, 200619 yr Ok, I know it's simple, but I'm stuck anyway... I need help! I need a script that will go to a related record (from a portal), using a layout that actually exists, showing only related results and then check if there is any foundcount... if not, it should create one and come back to original layout, if there are any, do nothing and come back to original layout. The problem is that on the "Go to related record" line, if there is no related record, I'm still on the original layout, and the foundcount returns the foundcount of the original layout, not the related one... What should I do? Is there another way to know if there are related records? Is there an error code associated with the line? (I get no error message, it just won't do anything...) I guess I could make a go to record, show all and constrain found sets, but the record is related to a global value... I can't set it in the criteria... Thanks Edited July 17, 200619 yr by Guest
July 17, 200619 yr I usually check to see if there are related records using IsEmpty. In other words, your script might look like this: If [isEmpty(RelatedTable::PrimaryKeyField)] Go to Layout ["RelatedTableLayout"] New Record/Request Set Field [RelatedTable::ForeignKeyField; Get(ScriptParameter)] Go to Layout [original layout] End If You'll need to attach the primary key from the parent record as an optional script parameter when you define the button to run the script above. This will allow the Set Field step to associate the new record in the child table to the parent record.
July 21, 200619 yr I was searching the archives to find out whether GTRR behaved oddly when there were no related records. And the answer is in this thread. Every programming instinct I have tells me that GTRR should go to an empty found set when there are no related records! The following procedure should work: Go to Record (First) Loop ..If (current_record_satisfies_some_condition) ....Go To Related Record(show only related records) ....Replace Field Contents(foo ; "xyzzy") ..End If ..Go To Record (Next ; Exit after last) End Loop It appears that, when there are no related records, the Replace Contents step changes every single record in the related table. Can anyone explain why this is somehow a good idea? Chap Counting from zero since 1970-something
Create an account or sign in to comment