cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

ACL to restrict attribute values for user selection

abolton
1-Newbie

ACL to restrict attribute values for user selection

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?

2 REPLIES 2

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

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

Top Tags