update state field by script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2024 07:02 AM - edited 07-19-2024 07:03 AM
Hi team
On RITM form we have UI action button after clicking that approval will be trigger script is working fine. But if approver approves the RITM i have to change the state to assigned ..how can we achieve this without workflow. If approver approves that particular RITM i have to change state can anyone help me in the script .I am using below script for approval triggering in UI action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2024 08:45 AM - edited 07-19-2024 08:45 AM
You could do it with a business rule on [sysapproval_approver] table that would:
- run when the state of the approval record changed to Approved
- get the RITM record to which the approval record belongs (based on the value of sysapproval field)
- change the state of the RITM record as needed
But what is the reason for not using a workflow?
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2024 08:55 AM
HI slava,
Because after submitting the catalog item there is no approval customer requirement is in case if they want any approval they will click on UI action button so that we are raising approval manually. Can anyone share the script it would be helpful for me thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2024 09:15 AM
In my opinion, this is not a valid reason for not using a workflow. You could have a workflow that would wait for the customer to trigger the approval. The appropriate solution depends on what the entire process looks like.
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2024 09:20 AM
Hi @Shabbir1 ,
You can create after business rule in "sysapproval_approver" table and set condition as state changes and changes to approved.
And go with below script to update the state.
var ritm = new GlideRecord('sc_req_item');
if(ritm.get(current.getValue('document_id')))
{
ritm.state = ‘approved’; // Required the backend value
ritm.update();
}
If you wants the this BR to run only for specific catalog item, then you can define condition in BR filter condition.