Newbies snc Posted March 31, 2006 Newbies Posted March 31, 2006 Hello all I'm trying to imitate the replace function in a portal. I used to have a pop-up menu so everybody is used to just choose a value and replace it in the current found set. Now that field is a portal, because I need it to hold more than one value. How would I set a selected list of records to one specific value in a portal? The problem is, that maybe some of the records already have that value. The script should just add the value to those records that don't have it yet. If you have an idea, please let me know.
Newbies snc Posted April 1, 2006 Author Newbies Posted April 1, 2006 Well, I figured something out. Somehow it does not look very elegant, but it works. Set Variable [ $tag; Value:_tags::special_features ] Go to Record/Request/Page [ First ] Loop Go to Field [ _tags::special_features ] [ Select/perform ] If [ _tags::special_features = $tag ] Go to Record/Request/Page [ Next; Exit after last ] Go to Portal Row [ First ] Else Go to Portal Row [ Select; Next ] End If If [ IsEmpty ( _tags::special_features ) ] Set Field [ _tags::special_features; $tag ] Go to Record/Request/Page [ Next; Exit after last ] Go to Portal Row [ First ] End If End Loop Commit Records/Requests
Ender Posted April 1, 2006 Posted April 1, 2006 Setting values in portals with looping scripts can get a little messy, especially if you need to add something later that changes the focus in the middle. It's generally better to jump to the related records and do the processing in there. Since you're replacing the value of a single field for all related records, you can employ the Replace[] function: Set Variable [ $tag; Value:_tags::special_features ] Go to Related Records [ Show only related records ; _tags ; layout: ] Replace [ _tags::special_features ; $tag ] Commit Records [ No Dialog ] Go to Layout [ original layout ] If the processing of each record were more complex, you could use a loop to go through all the records one-by-one, and set whatever you need to with branching If[]s and Set Field[]s (in this case, commit the record at each iteration.)
Recommended Posts
This topic is 6811 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 accountSign in
Already have an account? Sign in here.
Sign In Now