Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 7292 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I am creating a record that needs to relate to other records. My portals do not allow creation, only viewing.

I have now learned (thanks to this forum) how pass along one variable using the SET command and GET (ScriptParameter) where the GET (ScriptParameter) contains the data to enter into my new record to make it relative to my parent record.

My problem is that there are more than one parents who need to have their field content dumped into the new child record. I have three variables that need to be copied and pasted into the new child record.

How do I get more than one variable into the Get (scriptparameter) and then back out into three appropriate fields or is there a better way to do this?

Thanks

Posted

Concatenate the variables (with paragraph separators) into the script pararameter, then extract the variables using MiddleWords, LeftWords, or RightWords.

Posted

Note that using paragraph separators, you can use the MiddleValues function.

You can also do it the old-fashioned way, by setting the parent values into separate global fields, then in the child file, set the global values into the new record. The global fields can be in the parent or child, doesn't matter. Good housekeeping practice is to set the globals to "" (i.e., empty) at the end of your script.

Posted

Actually, any word separator will do just fine. I use pipe characters, something like:

Script Parameter would be: ID1 & "|" & ID2 & "|" & ID3

Then:

Set Field [ LeftWords(Get(ScriptParameter); 1) ]

Set Field [ MiddleWords(Get(ScriptParameter); 2;1) ]

Set Field [ RightWords(Get(ScriptParameter); 1) ]

The benefit of using pipes is that you can include them in layout names (and in other circumstances) to easily split and run your scripts depending upon the script parameters, ie, a layout named: Address|Copy IDs can be used to allow flexibility which can apply to many layouts - and perform many tasks without the need to hardcode at all. Using a carriage return would be more limiting.

Posted

How do I set the data into different fields? Where do I identify that in your example...

Could you show me an example using the following variables?

UserID | EventID | StatusID

They need to get dumped into related and identially-name fields in the child record...

Posted

I didn't identify the fields to set because they weren't indicated, Bill. I should have been clearer for you; my apologies. Your New Record script would be similar to this (after your script parameter captures the three IDs as UserID & "|" & EventID & "|" & StatusID:

Freeze Window

Go To Layout [ ChildRelationship table ]

New Record/Request

Set Field [ ChildRelationship::UserID; LeftWords(Get(ScriptParameter); 1) ]

Set Field [ ChildRelationship::EventID; MiddleWords(Get(ScriptParameter); 2;1) ]

Set Field [ ChildRelationship::StatusID; RightWords(Get(ScriptParameter); 1) ]

Commit Record/Request

Go To Layout [ Original Layout ]

This will copy the three parent IDs into the script parameter, freeze window so Users don't know what you're doing (smile), switch to your related table and create your new related record. When the User is returned to their parent layout, the new child record will appear in the portal.

Posted

Moonshadow, I like the simplicity of your approach but I have been investigating this and have found a possible problem using LeftWords, MiddleWords and RightWords. If any of the script parameter data, ie: in the current example if any of the ID fields contain &, - or _ it will consider those as indicating the start of a new word. The & and - are mentioned in the Help file for those particular functions, but I was surprised that the underscore also did this. As it is recommended in different places in the help file to use an underscore in place of a space for naming conventions. I do not know if this is a bug or not.

I would be interested in any feedback on this.

g

Posted

In this case, you might use return separated lists, as Fitch suggested, using RightValues(), MiddleValues(), and LeftValues(), (or just MiddleValues(),) to extract the values.

These extracted values have an extra line return in the result, so you have to remove it for text values.

Posted

Hi Geod, Mike ...

I'm not the best on text manipulations. Pipes work for me but I don't use strange characters - just straight words and my layouts all begin with table name then pipe then either action or description. I then can use this information in WindowNames, etc. Since LayoutNames with pipes works so nicely with script parameters (and you can't use carriage returns in layout names); and since I use script parameters with most of my layouts, this works well.

Now ... if I could only figure how to make script parameters work with table names and field names, I'd be one happy puppy!! But alas, maybe in vs. 8. smile.gif

Posted

When your values have more than one word, you parse them out using Left, Right, and/or Middle functions, as opposed to LeftWords, RightWords, MiddleWords. You determine the number of characters to parse using the Position function.

That will be a good learning exercise. Meanwhile, consider that once you create the new record in the child file, you should be able to grab the values from the parent record directly. I.e., it's not necessary to pass all the values via script parameter, only the ID of the parent record that establishes the relationship.

Another alternative is to create a TO/relationship in the parent file that allows creating of related records. Then you can create a new record just with a set field step. Another good technique to know.

This topic is 7292 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.