Jump to content
Server Maintenance This Week. ×

Replace in portals


snc

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

Recommended Posts

  • Newbies

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.

Link to comment
Share on other sites

  • Newbies

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

Link to comment
Share on other sites

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.)

Link to comment
Share on other sites

This topic is 6598 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.