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.

Unable to get values from HTML to Client script in UI Page

Dhanakoddi2
Tera Contributor

Hello,

 

I am creating a UI page with a textbox, but I am unable to get the value given in the textbox on click of submit button.

 

This is HTML part

 

<?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:ui_form>
    <div class="row">
        <span style="padding:16px; font-weight:bold;">Enter Google Document ID </span>
    </div>
    <div class="row">
        <textarea id="importArticlesID" name="importArticlesID" class="form-control" spellcheck="true" style="float: left; margin-left: 16px; width: 600px; height: 30px; border: 2px solid #000000; padding: 2px; overflow: hidden; word-wrap: break-word; resize: none;" required="required" type="text"> </textarea>                
    </div>
    <br></br>
    <div class="modal-footer" style="padding:16px;">
    <span class="pull-right">
        <button class="btn btn-default" onclick="return onCancel()" style="float: left; margin-right:20px; min-width: 5em;" title="" type="submit">Cancel</button>
        <button class="btn btn-primary" onclick="return importArticle()" style="float: left; margin-right:20px; min-width: 5em;" title="" type="submit">Import</button>    
    </span>
    </div>  
</g:ui_form>
</j:jelly>
 
This is Client Script part
function importArticle() {
   var textArea = $("importArticlesID");
   alert('Text : ' + textArea);
   var id = textArea.value.trim();
   alert('Value: ' + id);
  GlideDialogWindow.get().destroy();
}
function onCancel() {
    GlideDialogWindow.get().destroy();
    return false;
}
 
Could anyone help me to get the value of the textbox?
Thanks!
7 REPLIES 7

And when I click the module it opens in below URL

https://instancename.service-now.com/sn_google_docs_ImportArticlefromgDocs.do

 

But after clicking Import button the URL changed to 

https://instancename.service-now.com/ui_page_process.do?sys_id=d46dd47587c90650bedcc8040cbb3586

Found the issue. If the Direct checkbox is true then it is not working. If it Direct checkbox is false then it is working fine. Thanks for analyzing and reply for my issue.

Amit Pandey
Kilo Sage

Hi @Dhanakoddi2 

 

The code seems okay. What are you expecting?

 

Regards,

Amit