need to remove hard coded sys ids ?

Kiddy1
Tera Contributor

Developer Community harshtimes shloke04 explorenow

i need to remove the hard coded sysid value in my client script how to do it?

the script sets default assignment group i need to remove the hardcoded sysid value

function onLoad() {

//Type appropriate comment here, and begin script below

if(g_form.getValue('assignment_group') == '' && g_form.getValue('state') == 1 ){

g_form.setValue('assignment_group', "3a1fc5c5cd9d1100ef0e15a8c4f356");

}

}

6 REPLIES 6

shloke04
Kilo Patron

Hi,



Best practice would be to store your Sys_Id in a Property and then use it in the client side as mentioned below:



1) Navigate to sys_properties.LIST from Application Navigation bar and create a new property. Given a Name to your Property and paste the Sys Id in the Value field of the Property form.


2) Once the Property is created , create a Display Business rule on the same table on which you have written the above client script and call the property in the scratchpad variable as mentioned below:



Script:



g_scratchpad.property = gs.getProperty('Property Name');   // Replace your Property Name as created in step 1



3) Update your above Client script as mentioned below:



Script:



function onLoad() {


//Type appropriate comment here, and begin script below



if(g_form.getValue('assignment_group') == '' && g_form.getValue('state') == 1 ){


g_form.setValue('assignment_group', g_scratchpad.property);


}


}



This should work for you.



Hope this helps.Mark the answer as correct/helpful based on impact.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Kiddy1
Tera Contributor

shloke04



Thanks srivatsava for clear explanation with script



can you also help he on this



i have dom manipulation here in this case how to remove the hard coded sysids



function onLoad() {



setPreference('u_oppor', 'zztextsearchyy');


setPreference('u_order', 'zztextsearchyy');



var input_1=gel('sys_display.IO:26240d997c210200d307123a787929a');


var input_2=gel('sys_display.IO:4fa2dd7194620200d30762ae44b32a0');


var input_3=gel('sys_display.IO:768e3e49a18c4200ef0e4fb7a986adf');


var input_4=gel('sys_display.IO:7b2f72816f1c9e048f4f42dbea3ee4d');



if(input_1){


input_1.readOnly=true;}




if(input_2){


input_2.readOnly=true;}



if(input_3){


input_3.readOnly=true;}



if(input_4){


input_4.readOnly=true;


}


}


Thanks in advance


Kiddy1
Tera Contributor

shloke



if it is catalog client script what table name should i mention in display business rule?


For your first question regarding DOM manipulation, can you elaborate on the scenario what you are trying to achieve, would be easy to assist.



Answer to you second question is you need to write your Display BR on your target table i.e. which means after submission of your form if it is a catalog item you need to write it on Requested Item(sc_req_item) table and if it is a Record Producer you need to write it on the tartet table which you have selected on the record producer form to the table to which the ticket should be routed to after submission.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke