server code to populated values

Asmita7
Tera Expert

Hi friends,

 

I am working on code. 

 

 

assign();
function assign(){
gs.addInfoMessage('Hi');     ///// line 1
current.u_id = '123';            ///// line 2
current.u_cost = '123';         ///// line  3
 
}
 
line1 : Working
line 2 : Now working ... u_id field is not getting the value
line 3 : Now working ... u_cost field is not getting the value
 
Please note that I am working on a new record which is not saved. Please suggest the corrections or another approach.
 
Thank you
 
2 ACCEPTED SOLUTIONS

SunilKumar_P
Giga Sage

Hi @Asmita7, I have tried inserting the problem record by UI action on Incident table and update the problem field on Incident form with the created problem record. As your requirement is almost similar, can you try something like below?

var prbId = '';
var gr = new GlideRecord('problem');
createRecord();
updateProblemField();
action.setRedirectURL(current);

function createRecord(){
gr.initialize();
gr.short_description = current.short_description;
gr.description = current.short_description;
gr.assignment_group = current.assignment_group;
prbId = gr.insert();
}
function updateProblemField(){
	var grPrb = new GlideRecord('problem');
	if(grPrb.get(prbId)){
		current.problem_id = prbId;
		current.update();
	}
}

 

Regards,

Sunil

 

View solution in original post

Prathamesh G
Kilo Sage
Kilo Sage

Hello @Asmita7,

 

Please try with the below code to insert a new record in your desired table

 

var gr = new GlideRecord(table name);
gr.initialize();
//Set field mapping
gr.id = current.id;
gr.cost = current.cost;
var record= gr.insert();
current.field-from-your-current-table = record;
current.update();
	}
}
 

 

If the above answer resolve your issue, please mark the answer as Accepted solution and also mark it as Helpful.

 

Thank You

Prathamesh.

 

View solution in original post

2 REPLIES 2

SunilKumar_P
Giga Sage

Hi @Asmita7, I have tried inserting the problem record by UI action on Incident table and update the problem field on Incident form with the created problem record. As your requirement is almost similar, can you try something like below?

var prbId = '';
var gr = new GlideRecord('problem');
createRecord();
updateProblemField();
action.setRedirectURL(current);

function createRecord(){
gr.initialize();
gr.short_description = current.short_description;
gr.description = current.short_description;
gr.assignment_group = current.assignment_group;
prbId = gr.insert();
}
function updateProblemField(){
	var grPrb = new GlideRecord('problem');
	if(grPrb.get(prbId)){
		current.problem_id = prbId;
		current.update();
	}
}

 

Regards,

Sunil

 

Prathamesh G
Kilo Sage
Kilo Sage

Hello @Asmita7,

 

Please try with the below code to insert a new record in your desired table

 

var gr = new GlideRecord(table name);
gr.initialize();
//Set field mapping
gr.id = current.id;
gr.cost = current.cost;
var record= gr.insert();
current.field-from-your-current-table = record;
current.update();
	}
}
 

 

If the above answer resolve your issue, please mark the answer as Accepted solution and also mark it as Helpful.

 

Thank You

Prathamesh.