Need to check if the survey is sent through a scheduled job

rog
Giga Contributor

HI all,

I have a requirement where in I need to check if the survey is already triggered or not from the scheduled job. I am triggering a survey from the scheduled job, and if the response is no it will trigger a response incident.

1. I have created a field on the custom table to check if the survey is sent or not 'u_sent'. it is a true/false field I have created on the custom table.

var gr = new GlideRecord('custom table');

gr.addQuery('target date','<=', gs.daysAgo(0));

gr.addQuery('u_sent', false);

gr.query();

while(gr.next()){

        var surveyID = 'sys_id';

      (new sn_assessment_core.AssessmentCreation()).conditionTrigger(gr, 'trigger condition sys_id');

      gr.u_sent = true;

      gr.update();

}

But the problem is that, even after the scheduled job is run the u_sent value on the table is not changing to true but strangely it is coming as '0' once the record is inserted in to the table

find_real_file.png

It is causing the problem as it will not check the sent condition.

If the value selected on the survey is yes, I want the 'u_sent' to be false again so that it will send the survey again after a certain days.

2. if the response is yes it has to update a   certain field on the table to 100 days from the current date so that it will check in the scheduled job and trigger the survey next time again.

Can any one please help.

Thanks.

3 REPLIES 3

ark6
Mega Guru

I believe you are not passing it as a string inside a string field as a result of it is storing the boolean value.



Try gr.u_sent = "true";



rog
Giga Contributor

Hi Arka,



It is still giving same 0 value on the field.


rog
Giga Contributor

var gr = new GlideRecord('custom table');


gr.addQuery('target date','<=', gs.daysAgo(0));


gr.addQuery('u_sent_survey',No);


gr.query();


while(gr.next()){


        var surveyID = '176bb6ac137483004bd7bae32244b015';


  var createAssessmentOutput = (new SNC.AssessmentCreation()).createAssessments(surveyID,"",gr.u_name.sys_id);


  //(new sn_assessment_core.AssessmentCreation()).conditionTrigger(gr, '0fabb8e013f94740b4e65d422244b032');


  gs.log("test survey " + gr.u_name.getDisplayValue() + createAssessmentOutput);


  gr.setValue('u_sent_survey','Yes');


  gs.log("test survey ");


  gr.update();


}



I have created a new field 'u_sent_survey' whch is a choice type. trying to change the value to Yes once the survey is sent but it is not working.