Skip to main content
1-Visitor
March 15, 2016
Question

ACL to restrict attribute values for user selection

  • March 15, 2016
  • 1 reply
  • 1492 views

I want to be able to restrict an attribute's enumerated values presented for user selection without modifying the XML schema - can this be done with ACL?

    1 reply

    18-Opal
    March 16, 2016

    Hi Andrew--

    Sure, you can do this. Use the "modify_tag" doc callback to fix up the attribute value list, something like this:

    function mt_callback(doc, oid, win, op) {

      if (op == 1) { return 0; }

      # get doc ID

      local dlgdoc = _xmldlg::getDialogDocument(win);

      local tagname = oid_name(oid);

      # get list of attrs with enumerated values (comboboxes in modify attrs dlg)

      local attrs[], a;

      oid_xpath_nodeset(oid_root(dlgdoc),attrs,"//combobox");

      # find the attr we want to modify

      local values[], v, alias, attr;

      for (a in attrs) {

        attr = attrs[a];

        attrname = oid_attr(attr,"id");

        if (//attrname is attribute to be modified//) {

            # hide unwanted values

            local items[], i;

            oid_find_children(attr, items, "listitem");

            for (i in items) {

                local label = oid_attr(items[i],"label");

                if (//label should be removed//) {

                     oid_delete(items[i]);

                }

            }

         }

      }

    }

    Then, somewhere in your initialization code, make sure you add the callback:

    doc_add_callback(0, "modify_tag", "mt_callback");

    Replace the bits between double slashes //..// with proper tests and this will give you better control of the attribute values without having to modify the schema.

    --Clay

    abolton1-VisitorAuthor
    1-Visitor
    March 16, 2016

    Thanks Clay for the fast response (and documented code!).  I will try this and get back