1

I have added a new custom field in CMS_UserSettings table. The form control type is Multiple Choice. The data source for the control is set to a SQL Query. I would like to be able to populate the items in the control based on the selected user (Administration > Users). NOT the current user. Anyone know the syntax for this? Is it possible?

Here's my sample which pulls in the current users attribute. I need this to be the selected user.

SELECT ItemID, dealerNumber + ' - ' + dealerTitle 
FROM cPort_DealerLocation
WHERE culliganGroupID = {%CurrentUser.culliganGroupID#%}
ORDER BY ItemID

1 Answer 1

3

You can access currently edited object through EditedObject macro - {%EditedObject.FieldName%}.

Edit:

It seems that a custom macro method is needed to do this for documents. I was able to do this by following code: 1) Create custom macro method (for how to do it see the documentation

        MacroMethod method = new MacroMethod("MyEditedDoc", parameters => CMSContext.EditedDocument)
        {
            Type = typeof(TreeNode),
            Comment = "Returns currently edited document.",
            MinimumParameters = 0
        };
        MacroMethods.RegisterMethod(method);

2) Then in field editor of a document type you can use {%MyEditedDoc().DocumentName#%} and it gets resolved on the Form tab.

4
  • Does this only work with Users? I'm trying this in a Document Type and it doesn't seem to be working.
    – John B
    Nov 12, 2013 at 21:08
  • Yup, does not working for document type..any ideas..?
    – shamcs
    Apr 25, 2014 at 9:25
  • I've extended the answer on how to do it with documents.
    – mivra
    Apr 28, 2014 at 7:38
  • +1 Brilliant! I used this in some custom SQL query to populate a dropdown where I wanted to make decisions based on fields value on the current form, if one was already set. {%EditedObject.FieldName%} worked as you described
    – ne1410s
    Jan 29, 2016 at 10:34

Your Answer

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

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