The CreatorCon Call for Content is officially open! Get started here.

How to call script include from widget (client controller)

reddy8055
Tera Contributor

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

Harshal Aditya
Mega Sage

Hi @reddy8055,

 

You can call using GlideAjax.

The same way we call in client script

 

Regards

Harshal

GlideAjax is not supported in widget client controller (portal).

Sohithanjan G
Kilo Sage

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..:)

Hi,

GlideAjax is not supported in widget client controller (portal).