Need help with jelly script in UI Page

Satanik1
Giga Guru

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.

4 REPLIES 4

Amit Gujarathi
Giga Sage
Giga Sage

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



Thank you Amit. I rectified it But the issue is still not resolved. I still cant see the value in my textarea 😑

 

Thanks

Satanik

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



Hi Amit,

 

Apart from the missing uote did you make any changes on the script ? Unfortulately I dont see any other changes.

 

Thank

Satanik