Hello All, I am on appian 7.2. I want to set date field on form

Hello All,

I am on appian 7.2.
I want to set date field on form at run time.Use case is as follows,The use case ias follows,there are two date fields on form. I want to add fixed number of days to one of date field and calculation of this date and days to be shown on second date field.
I am able to do using ajax call and calling appian caladddays function.
But I am not able to set result in second date field.

Following is js code

importScript('/plugins/servlet/FormsExt.js');
var a=document.getElementsByName("dtEffectiveDate")[0].value;
          
          
          
          FormAPI.evaluateServerSideExpression(function(fn){

                              alert(fn);

                              
                              var c=new Date();
                              alert(c);
                              c=fn;
                              alert(c);
                              document.getElementsByName("dtCalculatedDate")[0].value=c;
c= document.getElementsByName("dtCalculatedDate")[0].value;
//alert(c);                              
                              }, ["addWorkingDaystoDate","2",a]);

Here I am getting correct value in variable 'c' but I am not able to set it for date fi...

OriginalPostID-103385

OriginalPostID-103385

  Discussion posts and replies are publicly visible

Parents
  • Once you have the new date you want to set, here's how you can set it:

    function setDateTimeField(dateFieldID, newDate){
    $('#date_date_'+dateFieldID+'_valueDateSingle_fd_component_'+window.FormDesigner.runtimeNamespace+dateFieldID+'_').val(newDate);
    $('#date_date_'+dateFieldID+'_valueDateSingle_fd_component_'+window.FormDesigner.runtimeNamespace+dateFieldID+'_').trigger('change');
    }

    The only thing I am doing here is retrieving the input field used for the date and setting its value with the val() function part of the JQuery API. In addition I am triggering the change event in order to notify the component that it has a new value and avoid validation errors if the field is required.

    Here's a sample application that changes the date of a field forum.appian.com/.../9614 The process model is under Process Models – Forum and is called Date with JS which comes with a JS file called dateUtilities located in Default Community > Temporary Documents Knowledge Center > Temporary Documents >JS libraries.
Reply
  • Once you have the new date you want to set, here's how you can set it:

    function setDateTimeField(dateFieldID, newDate){
    $('#date_date_'+dateFieldID+'_valueDateSingle_fd_component_'+window.FormDesigner.runtimeNamespace+dateFieldID+'_').val(newDate);
    $('#date_date_'+dateFieldID+'_valueDateSingle_fd_component_'+window.FormDesigner.runtimeNamespace+dateFieldID+'_').trigger('change');
    }

    The only thing I am doing here is retrieving the input field used for the date and setting its value with the val() function part of the JQuery API. In addition I am triggering the change event in order to notify the component that it has a new value and avoid validation errors if the field is required.

    Here's a sample application that changes the date of a field forum.appian.com/.../9614 The process model is under Process Models – Forum and is called Date with JS which comes with a JS file called dateUtilities located in Default Community > Temporary Documents Knowledge Center > Temporary Documents >JS libraries.
Children
No Data