- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-08-2022 06:05 AM
Hi All,
I need to make few fields read-only on RITM based on 1 sc_task closure. There are totally 5 tasks, but I want to make the fields read-only after 2nd task. Kindly suggest the way to proceed
I only have short description name unique for all the sc_Tasks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-08-2022 06:49 AM
You can write a display BR on RITM Table which queries sc_task table and store the value in scratchpad and use the same scratchpad in your client script.
1.Make sure your BR Trigger conditions apply for this catalog item.
code:
(function executeRule(current, previous /*null when async*/ ) {
var grScTask = new GlideRecord('sc_task');
grScTask.addEncodedQuery("short_description=shortdescription_value^request_item="+current.sys_id"^state=3"); //modify short description value.
grScTask.query();
if(grScTask.next()) {
g_scratchpad.task_completed= 'true';
else
g_scratchpad.task_completed= 'false';
})(current, previous);
You can use g_scratchpad.task_completed value in your client script and make variables read-only/editable.
alert("scratcpad value"+g_scratchpad.task_completed value);//testing purpose.
if(g_scratchpad.task_completed value == 'true')
{
//do something
}
else
{
//do something
}
check below links for similar requirrements
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-08-2022 11:00 AM
Hi priyanka
use this to get the request item sysid.
gs.addErrorMessage("RITM is " + current.request_item);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-09-2022 04:13 AM
Thanks, am able to get it with gs.addErrorMessage("RITM is " + current.sys_id);
Now, The number of records returning is 0, but it should show as 1.
var grScTask = new GlideRecord('sc_task');
grScTask.addEncodedQuery("short_description=Categorization task (project1 and project2)^request_item='+current.sys_id'^state=3");
gs.log("RITM sys id is " +current.sys_id);
grScTask.query();
gs.log("count is "+grScTask.getRowCount()); //returning 0 here even if state is closed
if(grScTask.next()) {
g_scratchpad.task_completed= 'true';
gs.log("completed is true");
}
else{
g_scratchpad.task_completed= 'false';
gs.log("completed is false");
}
It is going to false in the log, even after the sc_Task where short description('Categorization task (project1 and project2)) is closed complete
Kindly guide me here please. If I just give encoded query without requst_item='+current.sys_id, I am getting count as 30
and g_scratchpadtask_completed as true.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-09-2022 10:18 AM
Hi Priyanka
I missed a + symbol in above query, try below line.
grScTask.addEncodedQuery("short_description=Categorization task (project1 and project2)^request_item="+current.sys_id+"^state=3");
updated code:
var grScTask = new GlideRecord('sc_task');
grScTask.addEncodedQuery("short_description=Categorization task (project1 and project2)^request_item="+current.sys_id+"^state=3");
gs.log("RITM sys id is " + current.sys_id);
grScTask.query();
gs.log("count is " + grScTask.getRowCount()); //returning 0 here even if state is closed
if (grScTask.next()) {
g_scratchpad.task_completed = 'true';
gs.log("completed is true");
} else {
g_scratchpad.task_completed = 'false';
gs.log("completed is false");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-11-2022 11:05 PM
Did you get chance to check my answer?
If your issue is resolved now.
If yes, can you please mark appropriate response as correct for others who may have a similar question in the future and close this unresolved thread.
If not, please let us know if you need any other help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-13-2022 05:07 AM
Thankyou, Yes it worked well. I just applied and tested it today