Skip to content

Conversation

Adil404
Copy link
Contributor

@Adil404 Adil404 commented Oct 18, 2024

This business rule is to set state of sc_task table when sc_req_item state changes.
Create before insert/update business rule on sc_req_item table and give condition if state changes to 2 OR cat_item.sc.catalogs is "take your choice".

Create before insert/update business rule on sc_req_item table and give condition if state changes to 2 OR cat_item.sc.catalogs is "yourchoice"
readme file to provide details on business rule to change state.
@sandeepd26 sandeepd26 assigned sandeepd26 and unassigned sandeepd26 Oct 19, 2024
gr.orderBy('order');
gr.setLimit(1);
gr.query();
if (gr.next() && gr.getValue('state') == 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you added this condition to the query, you would not need to check the state for '1' (the magic number).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed "if" condition from the script, instead added inside the query.

var gr = new GlideRecord("sc_task");
gr.addQuery('request_item', current.sys_id);
gr.orderBy('order');
gr.setLimit(1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if more than one sc_task is under RITM?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed setLimit(1) so that it will update all the sc_task related to RITM


var gr = new GlideRecord("sc_task");
gr.addQuery('request_item', current.sys_id);
gr.orderBy('order');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to sort the results if you don't have a clear reason, in this case, you are sorting a list with one record.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the orderBy query

@Lacah Lacah self-assigned this Oct 20, 2024
Copy link
Contributor

@Lacah Lacah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have a look at the added comments and resubmit your script accordingly. Thanks.

updated the script : sc_task will change the state from open to work in progress when RITM state changes to work in progress (set this condition in filer condition).
Copy link
Contributor Author

@Adil404 Adil404 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the script : sc_task will change the state from open to work in progress when RITM state changes to work in progress (set this condition in filer condition).

Copy link
Contributor Author

@Adil404 Adil404 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update the script, please review it and let me know

@Adil404 Adil404 requested review from msdfib and Lacah October 21, 2024 13:59
Copy link
Contributor

@msdfib msdfib left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, leaving merge up to @Lacah

@Lacah Lacah merged commit c8c0892 into ServiceNowDevProgram:main Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants