Java Script to combine 3 fields into one
Looking for some Java Script coding help.
I have 3 fields that I would like to combine into 1 field. Using the below code, I can capture all 3 values and output it into a separate field ONLY when I use Chrome or FireFox. This code does not work when I use Internet Explorer.
Does the below code need to be modified in order to get it to work in IE?
function combinefields() {
var firstfield = $(CategoryCode).val();
var secondfield = $(FormatedDate).val();
var thirdfield = $(CurrentYear).val();
var tb6 = firstfield + thirdfield + '-' + secondfield;
$(WorkOrderNumber).val(tb6);
}
I would like my result to be: WorkOrderNumber = AF19-2810110233
Field data values.
CategoryCode = AF
FormatedDate = 2810110233
CurrentYear = 19
-
Hi James,
are you sure, you want to use JavaScript? For that the functions could be very usefull for you:
https://documentation.agilepoint.com/00/appbuilder/cloudjsGetFieldValue.html
https://documentation.agilepoint.com/00/appbuilder/cloudjsSetFieldValue.html
But if you just want to combine 3 fields into one - you could just use the formula control.
Feel free to ask further questions.
Regards,
Alexey
-
Alexey,
No, I not sure if I want to use JavaScript or not. I will use whatever works. I tried to use the formula control but since I want a dash in the output, I was told that I could not use that control for that. Is there a was in include the dash and not have the formula treat it as a minus?
Thank You,
James
-
Alexey,
I could not get the formula control to work since one of my fields are being populated from an Autolookup. If I manually type a value into this pre-populated field, then the formula works perfectly.
I was able to find a solution. I used the below code and had it run on Submit.
function getWorkOrderNumber() {
var code = getfieldValue('CategoryCode');
var date = getfieldValue('FormatedDate');
var year = getfieldValue('CurrentYear');
eFormHelper.setFieldValue({ fieldId: "WorkOrderNumber", value: [code, year,-date].join('')}, function(r){});}Thank you for your suggestions.
Regards,
James
Please sign in to leave a comment.
Comments
5 comments