How to copy value of a field from one form and use it in another form

Community Alums
Not applicable

Hi Team,

 

I have written a display BR to copy value in scratchpad on one form. I am trying to use it onLoad client script which is written on another form. When I am trying to print that value I am getting as Undefined.

 

Please suggest me how to get that value so that I can fetch value of other field based on that value

Below is used in Display BR:

g_scratchpad.edge=current.u_edge;
gs.info("hello :"+g_scratchpad.edge);

 

In OnLoad client script written on another form, when I am cheking I am getting infomessage as Undefined

var edge=g_scratchpad.edge;
g_form.addInfoMessage('client :'+edge);

 

If above way is incorrect, then tell me what approach I should follow?

7 REPLIES 7

RaghavSh
Kilo Patron

You mean to say your display BR and client script are on different tables? If yes then you need to use GlideAjax to get value in client script from different table.


Raghav
MVP 2023

Community Alums
Not applicable

I need to pass field value to GlideAjax which I am writting on Load of the form where I want the answer to populate but that field exist on a different table I am fetching that via display BR using scratchpad object.

 

function onLoad() {
//Type appropriate comment here, and begin script below

var sc=g_scratchpad.edge;
var ga = new GlideAjax('Edgesegment');
ga.addParam('sysparm_name', 'getCompany');
ga.addParam('sysparm_edge',sc);
ga.getXML(setcompany);

 

Below is the display BR:

g_scratchpad.edge=current.u_edge;
gs.info("hello :"+g_scratchpad.edge);

 

var sc=g_scratchpad.edge; you don't need this BR if it is on another table.

 You have already written glideAjax and script include, don't pass "sc" from client script, instead glide the table in your script include (Edgesegment) which contains the field "sc" value and d your operations accordingly.


Please mark the answer correct/helpful accordingly.

 

 


Raghav
MVP 2023

@Community Alums were you able to get this fixed?


Raghav
MVP 2023