Jump to content
Server Maintenance This Week. ×

How do I loop a Clear Search Highlight where ParentID has multiple ChildIDs?


Recommended Posts

Hi,

I have this script:

------------

If [ $$RecordClean [Child::ChildID] ]

Revert Record/Request [With dialog: Off ]

Set Variable [ $$RecordClean [Child::ChildID] ; Value: "" ]

Else

Set Field [Child::Value ; TextStyleRemove(Child::Value; If(Get(SystemPlatform) = 3; Bold; HighlightYellow) ) ]

End If

Exit Script [ Text Result: ]

------------

It's working correctly on the text field (Child::Value) of the first ChildID, but the search term stays selected from a previous search on the text field (Child::Value) of the remaining ChildIDs. TextStyleRemove should loop using the ParentID to perform the TextStyleRemove on ChildID 1, ChildID 2, etc. 

I hope this makes sense. Many thanks beforehand,

Daniel

Link to comment
Share on other sites

32 minutes ago, Quito said:

I hope this makes sense.

I am afraid not.

  • We don't know what your script is meant to accomplish;
  • We don't know from what context it is called;
  • You say it should loop (over child records??), but there is no Loop clause.

I am guessing you are on the parent record, trying to modify a child field. As you have noticed, a reference to a field in a related table is interpreted as reference to the field in the first related record. This is true for calculations (unless you are using an aggregate function) as well as for the Set Field step. If you want to modify all child records, you will have to create a found set of them and loop over it. Or do the same thing in a portal.

But before all that: there is a big red light flashing in your title. It looks like you are modifying a searched field so that the search term becomes highlighted (and after that you want to remove the highlights). This is not good practice, for two reasons:

  1. In a multi-user scenario, two users searching for different terms will clash with each other. And any user editing a record will prevent the highlight being turned on or off for another user performing the search;
  2. It will render your LastModified fields completely useless.

If you want to highlight the search term, use an unstored calculation field. And that should also solve the current problem (assuming I guessed correctly). All you would have to do is refresh the window.

 

 

Link to comment
Share on other sites

1 hour ago, comment said:

I am afraid not.

  • We don't know what your script is meant to accomplish;
  • We don't know from what context it is called;
  • You say it should loop (over child records??), but there is no Loop clause.

I am guessing you are on the parent record, trying to modify a child field. As you have noticed, a reference to a field in a related table is interpreted as reference to the field in the first related record. This is true for calculations (unless you are using an aggregate function) as well as for the Set Field step. If you want to modify all child records, you will have to create a found set of them and loop over it. Or do the same thing in a portal.

But before all that: there is a big red light flashing in your title. It looks like you are modifying a searched field so that the search term becomes highlighted (and after that you want to remove the highlights). This is not good practice, for two reasons:

  1. In a multi-user scenario, two users searching for different terms will clash with each other. And any user editing a record will prevent the highlight being turned on or off for another user performing the search;
  2. It will render your LastModified fields completely useless.

If you want to highlight the search term, use an unstored calculation field. And that should also solve the current problem (assuming I guessed correctly). All you would have to do is refresh the window.

 

 

Thank you, Comment,

You guessed correctly. I'll follow your advice and try the unstored calculation field first. Can you provide an extra hint on how to accomplish this?

Best regards,

Daniel

Link to comment
Share on other sites

Again, I don't know enough about your situation to make an intelligent suggestion. I suppose you want to use the same formula you used to add the highlight to the searched field. At its simplest, it could be something like:

Substitute ( YourField ; $$searchTerm ; TextStyleAdd ( $$searchTerm ; HighlightYellow ) )

But this may not be good enough because:

  1. Substitute() is case-sensitive;
  2. You may want to narrow the highlight to whole words.

Both of these are solvable, but require more work.

 

Link to comment
Share on other sites

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.