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

Filipe Cruz
Kilo Sage

Hello kartik,

That business rule is running in which table? 
Why aren't you doing this directly in the ui action when creating the problem record?

Robbie
Kilo Patron
Kilo Patron

Hi Kartik,

ServiceNow actually provide this functionality for you ' Out Of Box'.

You'll be able to see this functionality by right clicking at the top of the incident form and selecting the 'Create problem' menu option as shown below. 

To also enable this functionality as a button on the Incident form, go to:

'Configure' > 'UI Actions' (Again from right clicking at the top of the incident form.

Open the 'Create Problem' UI Action against the Incident table, and check the 'Form button' check box on the right hand side. (Again, shown below)

 

To help others, please mark correct and/or helpful.

Thanks,

Robbie

 find_real_file.png

 

Screen shot 2: Create Problem and 'Form button' check box:

find_real_file.png

Abhijit4
Mega Sage

Hi,

We already have OOTB UI action which does this job, is that UI action not showing problem created in problem field?

FYI : UI action is available in context menu which will be visible when Problem field is empty and state is not closed.

Let me know if you have any further queries.

Please mark this as Correct or Helpful if it helps.

Thanks and Regards,
Abhijit
Community Rising Star 2022

 

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP

kartik1
Tera Contributor

Thanks all for your quick responses. 

No worries with UI action which i have created. 

here i will elaborate more

1. I have created UI action named "Problem" on incident.

2. and i have made configuration that if i click on button which will create one problem record.

Nothing to worry about above steps.

NOTE: What i want to achieve is

1. Once the problem record is created, i want to populate that record number on incident form

(field - Peoblem (problem_id))