12

I'd like to use a custom URL popup to populate a second field in the component window in addition to the field that is being called by the custom URL.

Example: my form looks like this

    Category(custom URL attached): 
    (TEXT BOX HERE)

    Sub-Category: 
    (TEXT BOX HERE)

    Some Other field:
    (TEXT BOX HERE)

When a user clicks "category" and the custom URL window opens, I'll give them a chance to choose a drop down, then based on that drop down (using simple html/javascript) give an additional box for the subcategory (which will change based on the category value).

When the submit button is pressed I'd like to populate both Category and Subcategory from that original custom URL.

My current code looks like this:

function submitOutput(){
    var category = $("#categorySelect").val();
    var subCategory = $("#"+category+"SubCategory").val();
    var output = category+"::"+subCategory;

    var fields = window.dialogArguments.getFields();
    if (fields && fields.length > 0) {
        fields[0].setValues([output]);
    }

    //window.close();
}
12

Through window.dialogArguments you can access basically any field of the item.

Where window.dialogArguments.getFields() points to the current field (the one with the Custom URL on it), window.dialogArguments.container.getFields() will return you the entire fields collection of the item.

To get a specific field, you can use window.dialogArguments.container.getField('XML_FIELD_NAME').

note

Use the developer tools in your browser to check out which methods are available inside window.dialogArguments and a whole world should open up for you.

  • I did manage to get window.dialogArguments.container.getField("category").setValues(["foo"]) & window.dialogArguments.container.getField("category").setValues(["bar"]) to work, thanks so much! – Daryl H Jul 8 '13 at 21:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.