Update resolution Notes on Incident form based on solution

Rutuja K
Giga Guru

Hi,

There are 2 field on INC form, 1 solution, 2. Resolution Notes(Mandatory)

I am confused how to configure below scenario, 

If solution is empty and Resolution Notes is updated, I want to set solution = Resolution Notes.

If solution is not empty and Resolution Notes is updated, set Solution = Solution + Resolution Notes.

 

And Vice versa i.e. 

If Resolution Notes is empty and Solution is updated, I want to set Resolution Notes = Resolution Notes.

If Resolution Notes is not empty and Solution is updated, set Resolution Notes = Solution + Resolution Notes.

 

Thank You!

 

1 ACCEPTED SOLUTION

Sanjeeva Reddy1
Giga Guru

Hi Rutuja,

 

I tried with below code and it looks fine to me. You can create a Business Rule.

When: after

Update: True

Script:

(function executeRule(current, previous /*null when async*/ ) {
    if (current.u_solution.isEmpty() && current.close_notes.changes()) {
        current.u_solution = current.close_notes;
    } else if (!current.u_solution.isEmpty() && current.close_notes.changes()) {
        current.u_solution = current.u_solution + ' ' + current.close_notes;
    } else if (current.close_notes.isEmpty() && current.u_solution.changes()) {
        current.close_notes = current.u_solution;
    } else {
        current.close_notes = current.close_notes + ' ' + current.u_solution;
    }
    current.update();
})(current, previous);
 
I just want to check with you on below:
----------
If Resolution Notes is empty and Solution is updated, I want to set Resolution Notes = Resolution Notes. ---> Why do you need to set Resolution Notes again since Resolution Notes is empty?
----------
 

If the answer has helped you, please mark the answer as correct/helpful.

 

Regards,

Sanjeeva.Y.Reddy.

View solution in original post

8 REPLIES 8

Abdul Fathah
Mega Guru

Hi,

 

Write a business rule to achieve it. 

BR: Before update

Condition: solution changes or resolution notes changes

Script: 

if(current.solution == '' && res_notes.changes()){
current.solution = current.res_notes;
}
else if(current.solution != '' && current.res_notes.changes()){
current.solution = current.solution +'\n'+current.res_notes;
}
else if(current.solution.changes() && current.res_notes == ''){
current.res_notes= current.solution;
}
else if(current.solution.changes() && current.res_notes == ''){
current.res_notes= current.solution +'\n'+current.res_notes;
}

 

Thanks,

Abdul Fathah. 

Thanks,
Abdul Fathah
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

Thank you Abdul, I tried this script but

Lets say if Solution changes to "Test Solution 1" then BR runs and Resolution notes gets updated to "Test Solution 1"

Now if Resolution Notes are updated to "Test Solution 1_ Resolution Test 1", BR runs and updates Solution to "Test Solution 1

Test Solution 1_ Resolution Test 1"

 

I want Solution to update as "Test Solution 1_ Resolution Test 1" only

 

Sanjeeva Reddy1
Giga Guru

Hi Rutuja,

 

I tried with below code and it looks fine to me. You can create a Business Rule.

When: after

Update: True

Script:

(function executeRule(current, previous /*null when async*/ ) {
    if (current.u_solution.isEmpty() && current.close_notes.changes()) {
        current.u_solution = current.close_notes;
    } else if (!current.u_solution.isEmpty() && current.close_notes.changes()) {
        current.u_solution = current.u_solution + ' ' + current.close_notes;
    } else if (current.close_notes.isEmpty() && current.u_solution.changes()) {
        current.close_notes = current.u_solution;
    } else {
        current.close_notes = current.close_notes + ' ' + current.u_solution;
    }
    current.update();
})(current, previous);
 
I just want to check with you on below:
----------
If Resolution Notes is empty and Solution is updated, I want to set Resolution Notes = Resolution Notes. ---> Why do you need to set Resolution Notes again since Resolution Notes is empty?
----------
 

If the answer has helped you, please mark the answer as correct/helpful.

 

Regards,

Sanjeeva.Y.Reddy.

We want to keep Solution and resolution Notes in sync.