Need help with jelly script in UI Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2023 09:44 AM
Hello Experts,
I need a small help on the UI page. Please follow the below code:
<script language="javascript">
function openPopup(){
var gm = new GlideModal("open_content_helper",false,500);
gm.setTitle("Suggest a Description");
gm.setPreference("sysparm_shortDescription",g_form.getValue("short_description"));
var answer = "";
var ga = new GlideAjax('InvokeContentClarity');
ga.addParam('sysparm_name', 'getClarity');
var statement = g_form.getValue("description");
ga.addParam('sysparm_desc', statement);
ga.getXML(function myCallBack(response) {
var ans = response.responseXML.documentElement.getAttribute("answer");
gm.setPreference(sysparm_description",ans);
});
gm.setPreference("sysparm_sysid",g_form.getUniqueValue());
gm.render();
}
</script>
I want to setPreference on the GlideModal by fetching the return of the callback function (ans). But not able to set it. I think what I am writing is not correct.
Can anyone help me with the correct code please ?
Thanks
Satanik.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2023 10:18 AM
HI @Satanik1 ,
I trust you are doing great.
It looks like there is a syntax error in your code on this line:
gm.setPreference(sysparm_description",ans);
It seems that you forgot to include a quotation mark before sysparm_description. To fix this, you can modify the line to:
gm.setPreference("sysparm_description", ans);
This should set the sysparm_description preference on your GlideModal object with the value of ans returned by the callback function.
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2023 10:31 AM
Thank you Amit. I rectified it But the issue is still not resolved. I still cant see the value in my textarea 😑
Thanks
Satanik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2023 10:40 AM
Hi @Satanik1 ,
Please try putting this code in
<script language="javascript">
function openPopup(){
var gm = new GlideModal("open_content_helper",false,500);
gm.setTitle("Suggest a Description");
gm.setPreference("sysparm_shortDescription",g_form.getValue("short_description"));
var answer = "";
var ga = new GlideAjax('InvokeContentClarity');
ga.addParam('sysparm_name', 'getClarity');
var statement = g_form.getValue("description");
ga.addParam('sysparm_desc', statement);
ga.getXML(function myCallBack(response) {
var ans = response.responseXML.documentElement.getAttribute("answer");
gm.setPreference("sysparm_description",ans);
});
gm.setPreference("sysparm_sysid",g_form.getUniqueValue());
gm.render();
}
</script>
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2023 10:45 AM
Hi Amit,
Apart from the missing uote did you make any changes on the script ? Unfortulately I dont see any other changes.
Thank
Satanik