Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

UI Action and UI Page

Ayushi Saxena
Tera Contributor

UI Action to open an email compose window — allowing the user to manually write or customize the email body and triggering a notification.
To allow user input before sending the email.
When the user clicks a button on a Purchase Requisition (PR), open a modal to compose a custom email (To, Subject, Body) → then send it.

 

=================================

HTML in UI page 

<g:ui_form>
  <h2>Compose Email</h2>
  <form method="post">
    ...
    <input type="text" name="to" />
    <input type="text" name="subject" />
    <textarea name="body"></textarea>
    <input type="submit" value="Send Email" />
    ...
  </form>
</g:ui_form>
====================================
Server-side script in Ui page:

    var mail = new GlideEmailOutbound();
    mail.setTo("${to}");
    mail.setSubject("${subject}");
    mail.setBody("${body}");
    mail.setFrom(gs.getUser().getEmail());
    mail.send();

    alert("Email sent successfully.");
    GlideDialogWindow.get().destroy();
 
 ========================================
 
UI action code:
function composeEmail() {
    var dialog = new GlideDialogWindow('custom_email_modal');
    dialog.setTitle('Compose Email');
    dialog.setPreference('sys_id', g_form.getUniqueValue());
    dialog.render();
}


Geeting "Page could not found"
can anyone help me to debug this code. PFA 

 

 

1 ACCEPTED SOLUTION

KrishnaMohan
Giga Sage

Hi @Ayushi Saxena 

Please find below links which helps you clear idea about ui page and ui action like how to pass value from one component to another.

https://www.servicenow.com/community/servicenow-ai-platform-articles/ui-page-tips-and-tricks/ta-p/23...
https://www.servicenow.com/community/servicenow-ai-platform-articles/using-angularjs-in-ui-pages/ta-...

 

If my response was helpful in resolving the issue, please consider accepting it as a solution by clicking on helpful. or Accept solution button and giving it a thumbs up. This will benefit others who may have a similar question in the future.

 

Thanks

KrishnaMohan

View solution in original post

1 REPLY 1

KrishnaMohan
Giga Sage

Hi @Ayushi Saxena 

Please find below links which helps you clear idea about ui page and ui action like how to pass value from one component to another.

https://www.servicenow.com/community/servicenow-ai-platform-articles/ui-page-tips-and-tricks/ta-p/23...
https://www.servicenow.com/community/servicenow-ai-platform-articles/using-angularjs-in-ui-pages/ta-...

 

If my response was helpful in resolving the issue, please consider accepting it as a solution by clicking on helpful. or Accept solution button and giving it a thumbs up. This will benefit others who may have a similar question in the future.

 

Thanks

KrishnaMohan