Hello everyone, I need help regarding Advanced Forms Utilities, exac

Hello everyone,

I need help regarding Advanced Forms Utilities, exactly POPULATE DROPDOWNS DYNAMICALLY. First of all, I have two CDTs.
The first CDT has one text parametar which is dropdown list, range parametar - boolean (yes/no), and ID. The second CDT has the same ID, and values which is the second dropdown.
I want this, when I choose text value from the first dropdown, the first ID to connect with the second ID and based on the second ID to show values in the second dropdown list. I want it on click and change.

Can I use this:
FormAPI.populateDropdown("dropdown6", ["GetBusinessOriginDetailsByOriginCode", FormAPI.getValue("dropdown5").id], "code", "description");

or this:

FormAPI.populateDropdownFromCDT = function(dropdown, expr, id_attr, display_attr) {
FormAPI.evaluateServerSideExpression(function(list) {

var ids = [];
var displays = [];
for (var i=0;i<list.length;i++) {
ids[i]=list[i][id_attr];
displays[...

OriginalPostID-45172

OriginalPostID-45172

  Discussion posts and replies are publicly visible

  • ...i]=list[i][display_attr];
    }

    FormAPI.updateDropdownValues(dropdown,ids,displays);
    },expr);
    }

    I hope you can help me, give me a tip, or application example. Thanks!
  • Try the following:

    FormAPI.populateDropdownFromCDT("dropdown6", "=GetBusinessOriginDetailsByOriginCode(\\""+FormAPI.getValue("dropdown5").id+"\\")", "code", "description");
  • Hello, thank you for your response! But I need help in understanding the ("code", "description") and their meaning. Can you please tell me what they mean and how can I find them in my form. Thanks.
  • code and "description" are attributes of the CDT returned by the expression in the second parameter. In your case they should match attributes of the CDT returned by "GetBusinessOriginDetailsByOriginCode". These will be used to fill the IDs and value of the entries in the dropdown.

    The 3rd parameter ("code" in the example above) corresponds to IDs of the entries (e.g. 123,124) and the 4th parameter ("description" in the example above) corresponds to the values of the entries (e.g. Display Text 1, Display Text2).
  • You can find full documentation of the Advanced Form Utilities component attached to the component's page. Here's the direct link to the PDF with the documentation:
    forum.appian.com/.../34410

    If that still doesn't answer all your questions, let me know and I will gladly answer any remaining questions you may have.
  • Thank you for your response! The example was just and example, and my original code is FormAPI.populateDropdownFromCDT("dropdown84", "=GetValuerangeBySelectContract(\\""+FormAPI.getValue("dropdown13").id+"\\")", "TypeName", "Valueid"); which I write it on click and on change in my first dropdown filed. But the values in the second dropdown are blank. Do u know what maybe the error? Thanks
  • I have seen the documentation but still clueless about this type of error.
  • The synax is correct. You are using the "populateDropdownFromCDT" function correctly. You should only set it for the "on click" event, unless there is some other javascript that changes the values of the dropdown and you want it to trigger this code at that point. That being said, I don't think that is what's causing the issue you are experiencing.

    Without knowing the details of your system like the structure of the CDT you are getting and your DB structure, it's hard for me to say what's the issue but I can try and guide you to find it.
  • I would start by testing the "GetValuerangeBySelectContract" on a test expression rule with the values you have in "dropdown13" to make sure it's actually returning something. If that works, I would then check that "dropdown13" is configured to set the values the "GetValuerangeBySelectContract" rule expects on the "Value" property and not on the "Display Label" property. If that is not the issue either, then I will go to test the process instance itself to make sure that during runtime you are getting the right values. Maybe "dropdown13" doesn't populate the values properly during runtime because there's an issue with the expression used to configure it. Pay attention to typos as you go checking these areas.

    Hopefully you'll find the problem somewhere there.
  • Hey, tnx for your response. Here is my problem in specific.

    I have 2 CDT:
    First: ContractTypeDetails, with many fields like TypeName(text) and ValueRangeID(Number(Integer))
    which are the essential for me.
    Second: RangeofValues, with 2 fields: Valueid(Number(Integer)) and value(text).

    The expression rule for the first CDT is GetValuerangeBySelectContract with one parametar
    Contract (Text) and the definition is:
    =ContractTypeDetailsR2()[lookup(ContractTypeDetailsR2().typename,ri!Contract)].ValueRangeID

    I have tested it and it works, it returns the value range for specific contract.

    The query rule for the second CDT is VALUERANGES where I sort query results by Valueid.

    In my form I have 2 dropdowns:
    First: Contract Type (Text), Choose from process data (FieldID:dropdown13)
    Second: Value in range (Text), Choose from process data (FieldID:dropdown84)

    I have put this on load of the form:
    importScript('/plugins/servlet/FormsExt.js');

    and on the first form on click:
    FormAPI.populateDro