How can I pass information from g._user in client script?

Lon Landry2
Tera Contributor

I am trying to create a client script to display a system message based on the users language.

(This is a small part of what I am trying to do, but after failing for 20 hours; I am trying small bites.)

This is the code I am using:

function onLoad() {

var language = g_user.getLanguage();

    g_form.addInfoMessage(language);

}

I have also tried variations using

var loginLanguage = g_user.getClientData("loginlanguage");

With correct variables set,,,

And GlideAjax...

 

Thanks for your time,

1 ACCEPTED SOLUTION

as per my understanding it is acting like this way just because of we are dealing in different   scope. when you will try the same thing in global then it will work perfectly.


may i know your exact requirement?


View solution in original post

11 REPLIES 11

can you please share your script? i tested my above script and it has returned result


Client Script:


function onLoad() {


//Type appropriate comment here, and begin script below


alert(g_scratchpad.check);


}



Business Rule:



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



// Add your code here


g_scratchpad.check= gs.getUser().getLanguage();



})(current, previous);







ohh you are in scoped application that's why. g_scratchpad behave abnormal in scoped application .



by the way let's make it more simple.



can you try to only use g_lang variable in you client script.


eg:



function onLoad() {


    //Type appropriate comment here, and begin script below


    alert('My Language is: '+g_lang);


}


This works!



I was wondering what is up with g_scratchpad; I could get a return of text & math (functions) but not user (tried userName, ID, etc.) or session data.



Now I just have to figure out how to use this to show and hide fields using this g_form.setDisplay and an if / else statement.


as per my understanding it is acting like this way just because of we are dealing in different   scope. when you will try the same thing in global then it will work perfectly.


may i know your exact requirement?