Calculate a max value
I have a subform in an eForm, where the user enters a few inputs, one of them is a date.
I need to calculate the Latest date entered, so once this latest date has passed, I can send the user a notification with a new assignment.
For example if the user entered 3 dates : Feb 06 2021 , Oct 12 2021 , July 22 2021
I need a variable to get Oct 12 2021 - so I can send him a notification after this date.
Maybe there is a different way of achieving this? I've manage to calculate the number of days from *now* to each of the entered days, but still cannot find a MAX function. (There how ever a SUM function that sums all variables in a subform).
Would appreciate some help
Thank you
-
Hello Yana,
AgilePoint as helper methods to get the SubForm data. Please go through below documentation link for reference.
https://documentation.agilepoint.com/00/appbuilder/cloudjsGetSubFormData.html
https://documentation.agilepoint.com/00/appbuilder/cloudjsSetFieldValue.htmlPlease find the below code snippet to get the latest date entered. Hope this help.
function GetLatestDate()
{
var CompareDate ="";
var LatestDate = "";
var options = {};
options.fieldId = 'SubForm1';
eFormHelper.getSubFormData(options, function (result)
{
if (result.isSuccess)
{
$(result.data).each(function(i,v){
CompareDate = v.Date;
if(CompareDate>LatestDate)
{
LatestDate = CompareDate;
}
});
}
});
SetFieldValue('HiddenDateField',LatestDate) // save the the latest date Entered in the form field and make it hidden.
}
function SetFieldValue(ControlId,Date)
{
var options = {};
options.fieldId = ControlId;
options.value = Date;
eFormHelper.setFieldValue(options, function (result)
{
if (result.isSuccess) //check if is success
{
console.log(result.data); //logs the data holds empty object
}
});
}
Regards,
Aravind Rajanna
請登入寫評論。
評論
1 條評論