5

I am working on providing content editors a functionality where;

  1. They select a Keyword from a Category in field1 of Component.
  2. field2 Category will be based on Keyword selected in field1.

I used custom URL for this functionality and I am using Core Service to get the Category to be put in drop-down. I am saving the selected value for field1 in text file to be used for field2 dropdown, due to that the application is providing unexpected results if more that one editor are editing the Components. I tried following code to make sure that at any instance only one editor access the text file:

window.dialogArguments.controller.getItem().getLockedById()

but it will not work as the Component is not yet saved and userID or componentID is not yet created.

I have exhausted all the options available with custom URL to get it working correctly so I am now looking for better option than custom URL. Any suggestions would be appreciated.

5
  • 1
    It doesn't seem like the problem is with the custom URL functionality, but rather with the logic of needing to persist the data in the first place. I don't understand the reason for that. Surely the second drop-down can just be filled based on the value selected in the first, without persisting that choice anywhere -- right? Jun 28, 2017 at 7:51
  • @PeterKjaer Yes I need to persist the data. When user selects a value it is put into the component field and that works on popup=UID_XXX provided by the custom URL. If I submit the field1 popup, the UID is lost and I can not access the field2. So for each field I am having separate custom URL. Jun 28, 2017 at 12:02
  • 1
    I didn't quite understand that, but surely you can just read the selected value of the first field in the popup for the second field. You have access to all of the fields there... Jun 28, 2017 at 14:20
  • 1
    I'm curious, which of the fields are set to a specific Category? Is field1 a text field set to a Category? And field2 has the Custom URL that shows the keywords from a Category, somehow based on the Keyword selected for field1? Jun 28, 2017 at 20:54
  • Both fields are text fields. The custom URL shows dropdown from category. The category for field1 is specific but the category for field2 is determined based on value selected for first field. Jun 29, 2017 at 10:42

3 Answers 3

3

An alternative to a Custom URL would be a UI extension written with the Anguilla Framework, but that is certainly less trivial than using a Custom URL.

A Custom URL is focussed on the current field, or collection of fields in case of an embedded Schema (the one where the Custom URL is called from), which you get through window.dialogArguments.getFields(). But you can access any field of the Component and get its data.

Something like this example could could help you along I think (assuming the XML name of field1 from your question is xml_fieldname_field1):

// custom url called from field2
var field2 = window.dialogArguments.getFields();
var field2values = field2.getValues();

// get values of field1
var field1 = window.dialogArguments.container.getField('xml_fieldname_field1');
var field1values = field1.getValues();

So as you see, you have all the values you need in a single Custom URL call, and this will allow you to do exactly what you need without storing anything for a specific session or user.

2

As an alternative to CustomURL, the tree view option used with a Category with nested keywords is the built-in functionality to let an editor select an option based on another option.

But to @PeterK's points I've never seen the need to persist a selection as described in the question. If a field is set, you have the value in the field.

The cookbook and docs (and @Bart's answer) have examples of working with the fields from a Custom URL.

0

I think the below logic is causing the issues for you,

I am saving the selected value for field1 in text file to be used for field2 dropdown

To resolve the issue, try to store field1's selected value in browser's localstorage/sessionstorage instead of saving it in the text file.

Edit: If your custom URL is served by any serverside technology like ASP.NET, JSP, etc., you can persist the session values between the pages using it rather using the localstorage

2
  • Yes I know that is the issue but I am not able to persist the field1 value in localstorage or sessionstorage. When editor selects field1 value it gets put in field1 and the popup window is closed by me, this removes the local or session storage. I need to do close the field1 popup so that editor can open field2 popup and field2 dropdown value can be submitted in field2. Jun 28, 2017 at 12:06
  • Basically, you need to get around session management issues. I have updated my answer with other option :)
    – Rajesh
    Jun 28, 2017 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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