Java Script to combine 3 fields into one

Comments

5 comments

  • Avatar
    sysberry GmbH

    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

    0
    Comment actions Permalink
  • Avatar
    James Bilski

    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

     

    0
    Comment actions Permalink
  • Avatar
    sysberry GmbH

    James,

     

    try "-" for dash. So you have ${control}+"-"+${anothercontrol} and so on.

     

    Regards,

    Alexey

    0
    Comment actions Permalink
  • Avatar
    James Bilski

    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

     

     

    0
    Comment actions Permalink
  • Avatar
    sysberry GmbH

    Hi James,

    In Autolookup there is an option at the end of the configure to trigger change events to all target controls. This will also trigger the formula.

    Regards,
    Alexey

    0
    Comment actions Permalink

Please sign in to leave a comment.