Make the available values in a field in the checkout panel dependent on values in another field

You can use API tailoring to make the values that are available for selection in a field in the checkout panel dependent on the value in another field in the checkout panel. For example, you can configure the Device field to only display options available to the user who is defined in the Requested for field.

To do this, follow these steps:

  1. In the System Navigator, click Tailoring > Script Library.
  2. Enter ScAPI_SRCConfig in the Name field, and then click Search.
  3. Locate the following line of code:

    localizeLabelId(xml.getFirstChildElement(), language);

  4. Copy the following code before the localizeLabelId line:

    var fieldName = "";
    var queryString = "";
    if(srcConfig['screen.type'] =="")
    {
    var parent = xml.getParentNode();
    var sections = parent.getFirstChildElement();
    var section = sections.getFirstChildElement();

    while ( section != null )
    {
    var textNode = lib.xmlHelpers.getElement( section, fieldName, "field" );
    if ( textNode != null )
    {

    textNode.addAttribute("query",queryString);
    }

    section = section.getNextSiblingElement();
    }
    }

  5. Use var fieldName to define the field that will be dependent on another field.

    To do this, use the field name in the relevant table. For example, to define the Device field in the checkout panel, enter the logical.name field in the device table (var fieldName = "logical.name";).

  6. Use var queryString to set the field that will determine which values are displayed.

    To do this, use the field names in the relevant tables. For example, to define the Request for field in the checkout panel, enter the contact.name field in the device table and in the contacts table (var queryString= "contact.name =[contact.name]";).

  7. Click Save.