allow same location to select as per logged in user id location

Anubhav Srivas1
Tera Expert

Hi,

we have a variable set: "requested for country" which shows the logged in user details for the catalogue in SP.

 

based on the logged in user the country is displayed as "if the user is from India then it shows as india in requested for country" variable.

 

we want a variable "county used for" which is a lookup select box to allow users to select only India.

 

the lookup select box has multiple location in it which is coming from the table" u_razor_access_data_loolkup".

 

if the logged in user is from India and select the variable" country used for" as India then it should allow else it should show a popup to select the correct country and clear the value.

7 REPLIES 7

_Gaurav
Kilo Sage

Hi @Anubhav Srivas1 

You can use onchange client script here in the field "country used for".
Follow the steps:

1. Get the value of the Requested for country field and the new value selected by the user in Country used for.
2. Compare both the values, if they both are same then allow the user to proceed else, put an alert to show the message and clear the value by using g_form.clearValue('your_field_name',' ');

Please mark this as helpful if this resolves your query.
Thanks!

Hi,

 

can you please help me with the script?

 

Hi @Anubhav Srivas1 

1. Wirte a Onchange CS like this

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var requested_for_country = g_form.getValue('requested_for_country');

var ga = new GlideAjax('global.AbstractAjaxProcessor');  
ga.addParam('sysparm_name','check');
ga.addParam('sysparm_user_name',requested_for_country);
ga.addParam('sysparm_user_name1',newValue);
ga.getXML(HelloWorldParse);


function HelloWorldParse(response) {  
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
//here the answer will return 'same' and 'diff', please add the condition i.e. if 'diff' clear the field value
}}
 
2. Create a script include and add a method like this 
check : function(){
        var re_country = this.getParameter('sysparm_user_name');
        var re_country1 = this.getParameter('sysparm_user_name1');
        if(re_country == re_country1)
        return 'same';
        else
        return 'diff';
    },
 
 
Please mark this as helpful if this resolves your query and hit accepted as solution.
Thanks!

Hi Gaurav, even if i select the request for country as : INDIA and country used for as "india" still the popup message appears "diff", can you please help. IT is very important.