- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-11-2024 12:11 AM
I need to make the variable editor in the RITM read only after the RITM has been approved by the approver and it should also be made as read only if there is no approval for the RITM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-11-2024 01:39 AM
Hi @Sanafelix1323 ,
Greetings,
There is one OOB Client Script with name 'Variable Editor Readonly' this client script is making variables readonly on RITM Form. In order to make this field readonly when RITM is approved and when there is no approval, you can use a display business rule to get server-side values. Then, with the help of g_scratchpad, you can validate if RITM is approved or if there is no approval. Finally, edit the OOB Client Script to make variables readonly based on the g_scratchpad value. Please follow the scripts below to do so.
Display Business Rule -
(function executeRule(current, previous /*null when async*/ ) {
g_scratchpad.checkApproval = current.approval; // checking current state of approval
var grApprover = new GlideRecord('sysapproval_approver');//checking if approval is present there for RITM or not
grApprover.addQuery('sysapproval', current.sys_id);
grApprover.query();
if (grApprover.next()) {
g_scratchpad.checkApprovalIsPresent = true;
} else {
g_scratchpad.checkApprovalIsPresent = false;
}
gs.log("scratchpad - 2" + g_scratchpad.checkApprovalIsPresent, 'Check Approval');
})(current, previous);
Edited OOB Client Script -
function onLoad() {
if (g_scratchpad.checkApproval == "approved" || g_scratchpad.checkApprovalIsPresent == false) {//if approval is approved or if approval is not there then make variables readonly
g_form.setVariablesReadOnly(true);
} else {
g_form.setVariablesReadOnly(false);
}
if my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.
Thanks,
Astik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-11-2024 01:07 AM - edited ā04-11-2024 01:09 AM
@Sanafelix1323 By default, in OOB we have the Client scripts named "Variable Editor Readonly" for Catalog Task and Requested Item tables.
Note: It will be in "False" state as OOB.
You can use and modify it accordingly to the RITM states, post approval as well as by using "GlideAjax" you have the ability to query the approval table by passing the sys id of RITM record and then set readonly of the editor accordingly.
Please mark this as helpful and accept it as a solution if this resolves your query.
Thanks,
Sujatha V.M.
Sujatha V.M.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-11-2024 01:39 AM
Hi @Sanafelix1323 ,
Greetings,
There is one OOB Client Script with name 'Variable Editor Readonly' this client script is making variables readonly on RITM Form. In order to make this field readonly when RITM is approved and when there is no approval, you can use a display business rule to get server-side values. Then, with the help of g_scratchpad, you can validate if RITM is approved or if there is no approval. Finally, edit the OOB Client Script to make variables readonly based on the g_scratchpad value. Please follow the scripts below to do so.
Display Business Rule -
(function executeRule(current, previous /*null when async*/ ) {
g_scratchpad.checkApproval = current.approval; // checking current state of approval
var grApprover = new GlideRecord('sysapproval_approver');//checking if approval is present there for RITM or not
grApprover.addQuery('sysapproval', current.sys_id);
grApprover.query();
if (grApprover.next()) {
g_scratchpad.checkApprovalIsPresent = true;
} else {
g_scratchpad.checkApprovalIsPresent = false;
}
gs.log("scratchpad - 2" + g_scratchpad.checkApprovalIsPresent, 'Check Approval');
})(current, previous);
Edited OOB Client Script -
function onLoad() {
if (g_scratchpad.checkApproval == "approved" || g_scratchpad.checkApprovalIsPresent == false) {//if approval is approved or if approval is not there then make variables readonly
g_form.setVariablesReadOnly(true);
} else {
g_form.setVariablesReadOnly(false);
}
if my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.
Thanks,
Astik