Make fields read-only on RITM based on 1 task closure in sc_Task

Priyanka145
Tera Contributor

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

1 ACCEPTED SOLUTION

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

https://community.servicenow.com/community?id=community_question&sys_id=ca0e12bbdb89701414d6fb243996...

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

View solution in original post

11 REPLIES 11

Voona Rohila
Kilo Patron
Kilo Patron

Hi Priyanka

So you want to make fields readonly on RITM only after 1st CTASK is closed?


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Yes, correct

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

https://community.servicenow.com/community?id=community_question&sys_id=ca0e12bbdb89701414d6fb243996...

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Hi Rohila,

 

(function executeRule(current, previous /*null when async*/) {

    // Add your code here
    var grScTask = new GlideRecord('sc_task');
grScTask.addEncodedQuery("short_description='Categorization task (project1 and project2)'^request_item='+current.sys_id'^state=3");
    gs.addErrorMessage("RITM is " +request_item); // this msg is not triggering displaying
grScTask.query();
if(grScTask.next()) {
   g_scratchpad.task_completed= 'true'; 
}
else{
  g_scratchpad.task_completed= 'false';
}
})(current, previous);

I written the Display BR on RITM table 

Could you please guide me if I missed anything here