I have created UI action "Problem" on incident form and made configuration to create problem record when i click on "problem" button now i want to achieve that created problem number should get visible in problem field.

kartik1
Tera Contributor

I created BR, after insert/update

(function executeRule(current, previous /*null when async*/) {
var num = new GlideRecord('problem');
num.addQuery('number',current.parent.number);
num.query();
while(num.next())
{
num.problem_id = current.number;
num.update();
}

})(current, previous);

1 ACCEPTED SOLUTION

I think you can have it on the same UI action:

var newProblem = new GlideRecord("problem");

newProblem.initialize();

newProblem.setValue("short_description", current.getValue("short_description");

//similarly copy other fields as per your requirement

var problemSysID = newProblem.insert(); // returns sys_id of the newly created problem

current.setValue("problem_id",problemSysID);

current.update();

action.setRedirect(current); // if you set "current", will stay on same page. If you set "newProblem" it will redirect to newly created problem record.

Best Regards
Aman Kumar

View solution in original post

8 REPLIES 8

I think you can have it on the same UI action:

var newProblem = new GlideRecord("problem");

newProblem.initialize();

newProblem.setValue("short_description", current.getValue("short_description");

//similarly copy other fields as per your requirement

var problemSysID = newProblem.insert(); // returns sys_id of the newly created problem

current.setValue("problem_id",problemSysID);

current.update();

action.setRedirect(current); // if you set "current", will stay on same page. If you set "newProblem" it will redirect to newly created problem record.

Best Regards
Aman Kumar

Hi, Thanks for the answer, i have the same problem, i use your code and when i click on the button for create problem, an new incident form is created (same as create new record for incident). 

What have you done, if you can share the code/snapshot, I will be able to guide.

Hope you have followed this as well:

action.setRedirect(current); // if you set "current", will stay on same page. If you set "newProblem" it will redirect to newly created problem record.

Best Regards
Aman Kumar

hello @Aman Kumar S 

can you please help in understanding why my ui action script is not working. I added few alert messages and alert 3 is not getting displayed :

Client : true 

aka31289_2-1735904798205.png