- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2015 04:18 AM
I would like to write an action which is performed on multiple records from a list simultaneously.
This would be from a List view of a table, where the user has selected several records by ticking the selection boxes to the left of each record.
The standard processing for a UI Action, for example, would be to iterate through the selected items and do the action on each one-by-one.
Instead, I want to get all the ticked records into memory and then do a joint action on them.
As an example scenario, I may want to create a parent incident for a set of child incidents. I select the children-to-be, click a button on the List banner, and I get a new incident created in the background which summarises the situation in some way (perhaps with some user input) and sets the Parent Incident field on each of the selected incidents.
The key elements are:
- there is a single action (in my scenario, I don't want the user to have to create the parent incident first, and then have to link the children second).
- there is user interaction along the way, such as a confirmation or selection between options
- multiple users could be doing this action simultaneously so it cannot rely on flagging of records in the database - it has to read the specific user selections from the List
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2015 03:48 AM
You can certainly do that but it would need bit of scripting to accomplish this.
- First, make the UI action a client side one by checking the 'client' checkbox.
- Next, use this to get the list of sys_id's of the records that have been selected - g_list.getChecked();
- Next, iterate through the list if any of the records has parent field as non empty (This will handle both parallel user or action taken by other user case)
- If any of the record has parent field, do update gliderecord on the list of records got in the second step and update the parent field.
- If parent field is not found, create a record and update its sys_id to all the records as parent.
You can modularise the script and make use of separate functions to achieve specific results. Like a function to check parent field, another to update the parent field of records etc. This way you would be able to reuse the code better and make the code concise.
Hope that helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2015 03:19 AM
Hi John,
Just trying to understand here why a UI action would not fit your case?
You could mix client side scripting with server side in UI action and this should allow you to have your requirements satisfied.
Regards,
Sergiu

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2015 03:48 AM
You can certainly do that but it would need bit of scripting to accomplish this.
- First, make the UI action a client side one by checking the 'client' checkbox.
- Next, use this to get the list of sys_id's of the records that have been selected - g_list.getChecked();
- Next, iterate through the list if any of the records has parent field as non empty (This will handle both parallel user or action taken by other user case)
- If any of the record has parent field, do update gliderecord on the list of records got in the second step and update the parent field.
- If parent field is not found, create a record and update its sys_id to all the records as parent.
You can modularise the script and make use of separate functions to achieve specific results. Like a function to check parent field, another to update the parent field of records etc. This way you would be able to reuse the code better and make the code concise.
Hope that helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2015 07:33 AM
Thanks, Kalai - that's just what I need!