Info Needed

Abdul
Tera Contributor

Hi 

 

i would like to know how this scenario can be done.

I have a variable named "Expenditure type" and this expenditure type has a value named"Lease"

the "Lease" should be visible only for the users from the US. (i,e) when the user's email id ends with @usa.com 

 

Can you please help me with this

1 ACCEPTED SOLUTION

Chaitanya ILCR
Kilo Patron

Hi @Abdul ,

create this client callable script include

var CheckUserEmailDomain = Class.create();
CheckUserEmailDomain.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    isParklandUser: function() {

        var email = gs.getUser().getEmail();

        return email && email.endsWith('@usa.com');
    }

});

 

ChaitanyaILCR_1-1749203209124.png

you may see the highlighted field as Client callable ( check it )

 

create onload client script

 

function onLoad() {
    var expenditureType = 'u_expenditure_type'; //update this with expenditure type varialbe name if required
    var ga = new GlideAjax('CheckUserEmailDomain');
    ga.addParam('sysparm_name', 'isParklandUser');
    ga.getXMLAnswer(function(response) {
        if (response == 'true' || response == true)
            g_form.removeOption(expenditureType, 'lease'); // is lease is the backend value of lease choice else update it with correct value
    });

}

ChaitanyaILCR_2-1749203325606.png

update the variable names and choice values if required with correct values

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

View solution in original post

7 REPLIES 7

Abdul
Tera Contributor

can you please help me

 

Chaitanya ILCR
Kilo Patron

Hi @Abdul ,

create this client callable script include

var CheckUserEmailDomain = Class.create();
CheckUserEmailDomain.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    isParklandUser: function() {

        var email = gs.getUser().getEmail();

        return email && email.endsWith('@usa.com');
    }

});

 

ChaitanyaILCR_1-1749203209124.png

you may see the highlighted field as Client callable ( check it )

 

create onload client script

 

function onLoad() {
    var expenditureType = 'u_expenditure_type'; //update this with expenditure type varialbe name if required
    var ga = new GlideAjax('CheckUserEmailDomain');
    ga.addParam('sysparm_name', 'isParklandUser');
    ga.getXMLAnswer(function(response) {
        if (response == 'true' || response == true)
            g_form.removeOption(expenditureType, 'lease'); // is lease is the backend value of lease choice else update it with correct value
    });

}

ChaitanyaILCR_2-1749203325606.png

update the variable names and choice values if required with correct values

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

Rick62
Tera Expert

Thanks for helping @Chaitanya ILCR 
@Abdul looks like you had the script include and glide ajax correct...just needed to use g_form.