Question

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
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top