The Zurich release has arrived! Interested in new features and functionalities? Click here for more

I need help to Autopopulate a field. Also, I need help on Date validation

ID NOBLE
Tera Expert

1. Auto-Populate Description Field: Please I need help on the following requirements. 

Whenever we make changes to the Requester field, we want to auto-populate the description field with Requester's information. (e.g Requester email, Requester number, Requester department)

 

2. Date Validation on MASCOTH Table: WE want to make sure that the ‘Date’ field on the ‘MASCOTH’ table does not accept past dates (today’s date is allowed, but past dates are not allowed). That's, only allow record update if the ‘Date’ is a future date.

 

3. Create a Boolean Field: We want to create a Boolean type field called "INQUIRE on the ‘MASCOTH’ table.

 

Thank you all.

2 REPLIES 2

pratik_karande
Tera Contributor

Hello @ID NOBLE,

"1. Auto-Populate Description Field: Please I need help on the following requirements. 

Whenever we make changes to the Requester field, we want to auto-populate the description field with Requester's information. (e.g Requester email, Requester number, Requester department)"
-->> You can do this by writing an on change client script on the requester field and a script include as follows:
on change client script on Requestor field :

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

    var requestor = newValue;
    var a = new GlideAjax('global.getRequestorInfoUTILS');
    a.addParam('sysparm_name','requestorDetails');
    a.addParam('sysparm_reqid',requestor);
    a.getXMLAnswer(responseParser);
}
function responseParser(answer){
    g_form.setValue('description',answer);
}
 
Script Include (Client Callable):
var getRequestorInfoUTILS = Class.create();
getRequestorInfoUTILS.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    requestorDetails : function(){
        var req_sysid = this.getParameter('sysparm_reqid');
        var user = new GlideRecord('sys_user');
        user.addQuery('sys_id',req_sysid);
        user.query();
        if(user.next()){
            return 'Requested mailID- '+user.email+', Requester mobile phone- '+user.mobile_phone+',  Requester Department- '+user.department.getDisplayValue();
        }
    },

    type: 'getRequestorInfoUTILS'
});
/////Replace the field values as per your requirement/////
 
2. Date Validation on MASCOTH Table: WE want to make sure that the ‘Date’ field on the ‘MASCOTH’ table does not accept past dates (today’s date is allowed, but past dates are not allowed). That's, only allow record update if the ‘Date’ is a future date.
------>>refer this acticle https://www.servicenow.com/community/developer-articles/no-code-date-validations-through-catalog-ui-...

3. Create a Boolean Field: We want to create a Boolean type field called "INQUIRE on the ‘MASCOTH’ table.
--->>> You can use a "YES/NO" field type for this purpose

Please mark the answer correct if it helped in fulfilling your requirements. 

 

 



jitendrag
Tera Expert

@ID NOBLE  If this is on Catalog item than I have used the Single line text variable type and auto Populated the value based on the Requested for field. 

 

Added all this details via flow to my RITM and SCTASK description and also added in Email

 

jitendrag_0-1728893624799.png