How to call script include from widget (client controller)
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2023 02:20 PM
Hi,
How to call script include from Client controller within widget.
Script include:
var Persona = Class.create();
Persona.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isAssessmentTaken: function() {
var surveyid = this.getParameter('sysparm_surveyid');
var user = "";
user = gs.getUserID();
var retVal = "";
var rec = "";
var query1 = "";
query1 = "metric_type=" + surveyid + "^user=" + user + "^state=ready";
gr = new GlideRecord('asmt_assessment_instance');
gr.addEncodedQuery(query1);
gr.query();
if (gr.next()) {
retVal = gr.sys_id;
}
return retVal;
},
type: 'Persona'
});
Client controller:
function(spModal) {
/* widget controller */
var c = this;
spModal.open({
title: 'Persona',
widget: 'my_surveys_2',
size: 'lg',
backdrop: 'static',
buttons: ['', ''],
backdropClass: 'background-color: rgba(0, 0, 0, 0.4)',
widgetInput: {
//instance_id: result,
type_id: 'f0a6037c9775212101eaade24a253afc7'
},
buttons: [{
label: 'Cancel'
},
{
label: 'Ok',
cancel: true,
primary: true
}
]
}).then(function() {
location.href = '/logout.do';
})
c.data.popup_triggerred = true;
c.server.update();
}
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2023 03:14 PM
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2023 11:55 AM
GlideAjax is not supported in widget client controller (portal).
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2023 11:52 AM
Hi @reddy8055
You can call in this way
var ga = new GlideAjax('scriptincludename');
ga.addParam('sysparm_name', 'isAssessmentTaken');
ga.addParam('sysparm_surveyid', 'YOUR_SURVEY_ID');
ga.getXML(function(response) {
var answer = response.responseXML.documentElement.getAttribute('answer');
if (answer === 'true') {
} else {
}
Mark as accpeted if it helped you
Please mark as Accepted Solution if this solves your query and HIT Helpful if you find my answer helped you. This will help other community mates too..:)
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2023 11:54 AM
Hi,
GlideAjax is not supported in widget client controller (portal).