Passing text area values into a Processing Script

Feddy
Kilo Sage

Hi Team , 

I need to make worknotes mandatory when reopen action is clicked. 
The issue is the reopen action will be visible only on closed problem and the worknote field  is restricted using write ACL on closed tickets. I cannot modify a ACL. 
I have created a ui page in order to ask make the popup text area later copying the value to worknotes. Even this is not working. Please help me how to pass text area value to processing script and update the text area value to worknotes.

My Ui action Script : 

var ConfirmReopenDialog;

function reopenProblem(){    //onclick of the ui action
var sysId = g_form.getUniqueValue();
ConfirmReopenDialog = new GlideModal("pep_worknotes_dialog", false);
ConfirmReopenDialog.setTitle(new GwtMessage().getMessage("Re-open Problem"));
ConfirmReopenDialog.setPreference('sysparm_sys_id', sysId);
ConfirmReopenDialog.render();
}
//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
updateProblem();

function updateProblem(){
current.state = 7;
current.update();
action.setRedirectURL(current);
}
--------------------------------------------------------------------------------------------------------------------------------------------

In my UI page, 

My HTML is 

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:dialog_notes_ok_cancel
dialog_id="pep_worknotes_dialog"
textarea_id="work_notes"
textarea_label="${gs.getMessage('Work notes')}"
textarea_name="work_notes"
textarea_onkeyup="enableButton()"
textarea_style="height:auto; width: 100%; resize: vertical;"
textarea_title="${gs.getMessage('Enter the reopen reason here')}"
ok=""
ok_id="confirm_ok_btn_prb"
ok_action="ReopenProblem"
ok_title="${gs.getMessage('Reopen the Problem')}"
ok_type="button"
ok_style_class="btn btn-primary disabled"
cancel_title="${gs.getMessage('Close the dialog')}"


/>
<g:ui_form>
<g:dialog_notes_ok_cancel ok="return true" />
<input type="hidden" name="incident_id" value="SYS_ID_OF_TICKET"/>
<textarea id="comments" name="comments"></textarea>
</g:ui_form>

</j:jelly>


-------------------------------------------------------------------------------------------------------------------------

my client script in ui page is 

function ReopenProblem() {
var text = $("work_notes");
var textArea = "Reopen Reason : "+text.value.trim();
GlideModal.get().destroy();
g_form.setValue('work_notes',textArea);  ///// This is not happening since the field is restricted write acces

gsftSubmit(null, g_form.getFormElement(), "reopen_problem");
}

---------------------------------------------------------------------------------------------------------------------------


Please let me know how to get the value of text area value as well as problem sys id so that i can update the value in processing script

Thanks in Advance

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@feddy 

pass the sys_id as below

Either do GlideRecord or GlideAjax

<input type="hidden" id="incident_id" name="incident_id" value="${sysparm_sys_id}"/>

function ReopenProblem() {
var text = $("work_notes");
var textArea = "Reopen Reason : "+text.value.trim();
GlideModal.get().destroy();

var sysId = gel('incident_id').value;

var gr = new GlideRecord('problem');

gr.get(sysId);

gr.work_notes = textArea;

gr.update();

gsftSubmit(null, g_form.getFormElement(), "reopen_problem");
}

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

7 REPLIES 7

Yes, it simply destroys the glidemodal and nothing is happening.
is there any issue with the script?
from starting it was working for admin , not for other users.

Thanks
Feddy

@feddy 

If this setup is in your personal instance and you are ok to share details url and some admin credentials then share here -> ankurb.snow@gmail.com

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@feddy 

Hope you are doing good.

Did my reply answer your question?

If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.

If not, please let us know if you need some more assistance.

Thanks!
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader