In onsubmit client script i can able to get value from glide ajax but that value is not assiging? t
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2023 07:54 AM
In onsubmit client script i can able to get value from script include but can't able to assign value to field i don't know what is issue please help out ?
code is as below:-
client script:-
function onSubmit() {
var glideDateTime = new GlideAjax("DOMSPOAjaxUtils");
glideDateTime.addParam("sysparm_name", "currentDateTime");
//glideDateTime.getXMLWait();
glideDateTime.getXML(getResponse);
//var answer = glideDateTime.getAnswer();
function getResponse(response) {
alert('Hi121');
var answer = response.responseXML.documentElement.getAttribute("answer");
if (g_form.getValue('state') == '2') {
alert('Hi' + answer);
g_form.setValue('u_hold_start', answer);
g_form.setValue('u_hold_end', '');
} else {
if (g_form.getValue('u_hold_start') != '') {
g_form.setValue('u_hold_end', answer);
}
}
}
}
script include:-
var DOMSPOAjaxUtils = Class.create();
DOMSPOAjaxUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
currentDateTime: function() {
var glideRecord = new GlideDate();
var gDate = glideRecord.getByFormat('MM/dd/YYYY hh:mm:ss a');
gs.log('Hi3242342'+gDate);
return gDate;
},
type: 'DOMSPOAjaxUtils'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2023 10:06 AM
What is the value you get in your answer alert, which would be more useful outside of the if block so that you see what is returned regardless of the other conditions. What is the type of the u_hold_end field/variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2023 07:39 PM
Hi @Brad Bowman
In answer I will get current date and time.u_hold_end is a date/time field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2024 06:48 PM
Hi @Brad Bowman ,
Answer will return current date and time u_hold_end is a date and time field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2023 09:28 PM
As you are using Client Script and that too onSubmit Functionality, As of my knowledge i guess you are using Widgets in ServicePortal. If you can see in the widgets,there will be sections namely
1. HTML Template
2. CSS - SCSS
3. Client Script
4. Server Script
5. Link Function
6. Demo Data (JSON)
As of your requirement , you can use Client Script and Sever Script sections along with the HTML and CSS (depending on your requirement). There is no need to use Script Include like in other cases
The main important concepts in that is
1.How to send data from server to client ( For that we have an object called data which is used to send the data)
2. how to fetch that data that is being sent ( we will use this.data to get that data)
And similarly we have some functions(async) namely
1.c.server.get()
2.s.server.update()
Here are the Screenshots of that code .I have tried this on my system and it worked.
Thank you,
Kumar Raja