Jump to content

Script keeps filling in the same portal row


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

Recommended Posts

  • Newbies

This problem is related to a script, portal and value list, so I hope I'm posting to the correct forum.

I have a layout where I'm using a pop-up menu (field name: StandardInfoRelatedPages) to populate three fields in a portal. The pop-up menu is populated by a value list. The value list is kind of complicated because each "value" actually contains three bits of information, which are a title/headline, URL and description (for example: My Site^http://www.mysite.com^Generic description). These bits are separated by a "^" character.

Once a value is selected in the list, you may click a button that triggers a script that parses the value list and fills in the title/headline, URL and description portal fields (from the database named RelatedPages) with the appropriate information.

This process works correctly the first time it is performed. However, if I try to add another value from the value list, the new value replaces the first value instead of filling in the second row of the portal. I have tried setting the Go to Portal Row script step to "Next" at the end of the script, but it doesn't appear to be making any difference.

I have included the text of the script below to make the problem clearer. Is there anything I'm missing? Any help would be greatly appreciated.

Set Field [ RelatedPages::Title, Left(StandardInfoRelatedPages, (Position(StandardInfoRelatedPages, "^", 1, 1) - 1)) ]

Set Field [ RelatedPages::Link, Middle(StandardInfoRelatedPages, Position(StandardInfoRelatedPages, "^", 1, 1) + 1,

Position(StandardInfoRelatedPages, "^", 1, 2) - Position(StandardInfoRelatedPages, "^", 1, 1) - 1) ]

Set Field [ RelatedPages::Description, Right(StandardInfoRelatedPages, Length(StandardInfoRelatedPages) -

Position(StandardInfoRelatedPages, "^", Length(StandardInfoRelatedPages), -1)) ]

Set Field [ StandardInfoRelatedPages, "" ]

Go to Portal Row [ Next ]

Link to comment
Share on other sites

You can always have a global field that captures the next portal row value and set it to that in your script (last +1). The portal row [next] function works with the last active portal the user has clicked on when the script is run.

Link to comment
Share on other sites

Hi,

You'd better move to a multi predicate relationship, specially designed for this record creation, and set to allow creation of related records.

You don't need any portal for this, just the one you have right now to check data was entered, that should have the primary_key matching the foreign_key.

The relation between your Current Table and the new ocurrence of the RelatedTable (call it Related_Create) would be :

gTitle = Title

gLink = Link

gDescription = Description

gUniversal_key = yourSerial Number.

So that you script now becomes.

SetField[gTitle; YourTitleParsingCalc]

SetField[gLink; YourLinkParsingCalc]

SetField[gDescription; YourDescriptionParsingCalc]

SetField[gUniversal_key; GetAsNumber("")]

SetField[RelatedCreate::foreign_key;CurrentTable::primary_key]

SetField[gTitle; ""]

SetField[gLink; ""]

SetField[gDescription; ""]

SetField[gUniversal_key; GetAsNumber("")]

CommitRecordRequest

HTH

Link to comment
Share on other sites

  • Newbies

Thanks to both of you for your help. However, I found a solution from a different source. Here's the new script:

Go to Field [ RelatedPages::Title ]

Go to Portal Row [ Last ]

Set Field [ RelatedPages::Title, Left(gStandardDescription, (Position(gStandardDescription, "^", 1, 1) - 1)) ]

Set Field [ RelatedPages::Link, Middle(gStandardDescription, Position(gStandardDescription, "^", 1, 1) + 1,

Position(gStandardDescription, "^", 1, 2) - Position(gStandardDescription, "^", 1, 1) - 1) ]

Set Field [ RelatedPages::Description, Right(gStandardDescription, Length(gStandardDescription) -

Position(gStandardDescription, "^", Length(gStandardDescription), -1)) ]

Set Field [ gStandardDescription, "" ]

Exit Record/Request

Refresh Window

I think this works because the Go To Portal Row step is at the top of the script and the Refresh Window script is at the bottom. However, if anyone can offer a more concrete and thorough explanation, I'd certainly enjoy reading it. [color:"blue"]

Link to comment
Share on other sites

Your portal is then set to "allow creation of related records".

When targetting the last row, you'd actually be automatically filling a new record from the portal relationship.

If it weren't (set to "allow creation of related records" ) you'd be filling the last valid record and your post title wouldn't change this much as you'd always be setting the same row, that is to say replacing data into the last one.

Link to comment
Share on other sites

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