Client script to work only when the record is active

Thrupthi
Tera Expert

Hi,

I have two forms as mentioned below

1. SIM

2.Company phone

I have return the below client script to populate assigned to information from company phone table in SIM form, when phone number field is populated and it is working fine.

I want the help for little additional thing, that is this client script should work only when both SIM and Company phone number is active.

The field is Active (u_active). How do i do it?

 

Client script:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {

var lp = new GlideAjax('Displaysimassignedto');

lp.addParam('sysparm_name','simassignee');

lp.addParam('sysparm_simdetails',g_form.getValue('u_associated_phone_number'));

lp.getXML(assignees);

function assignees(response)

{

var answer = response.responseXML.documentElement.getAttribute("answer");

g_form.setValue("u_assign", answer);

}
}

1 ACCEPTED SOLUTION

I just noticed that in the last script i gave you i wrote  if(g_form.getValue('u_active')=='false') while it should be if(g_form.getValue('u_active')==true)

Can you check if you used true or false in the if condition?

-Anurag

View solution in original post

32 REPLIES 32

siva_
Giga Guru

Before i proceed i wanna ask you some questions 

1) Do you have an active field on your table and also on your form ??

 if so what is its name?

Post that just change the code as below and that should work 

NOTE : IF YOU DONOT HAVE ACTIVE FIELD ON YOUR FORM OR TABLE MAKE SURE YOU CREATE ONE ACTIVE FIELD AND THEN RUN A BACK GROUND SCRIPT TO UPDATE THE RECORDS(EXISTING ) ACCORDINGLY 

 

if you have any other variable which can let us know the status of active flag of the record you can use that in your client script 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {

if(g_form.getValue("u_field_name")){ //if you have active field (insert its name here) else if you have any other field, use that field name here 

 

var lp = new GlideAjax('Displaysimassignedto');

lp.addParam('sysparm_name','simassignee');

lp.addParam('sysparm_simdetails',g_form.getValue('u_associated_phone_number'));

lp.getXML(assignees);

}

function assignees(response)

{

var answer = response.responseXML.documentElement.getAttribute("answer");

g_form.setValue("u_assign", answer);


}

 

 

Hope this helps 

 

Thanks

Siva

 

MArk this response as correct if that really helps 

 

Thanks,

Siva

 

Hi Siva,

 

Yes i do have the active field both on my form and table its "u_active", 

The script above still doesn't work, it populates data even if the record is inactive.