Can any one please help me to set the attribute in Read - Only mode by DXL Scripting in a view ?
Accepted answer
You cannot make an attribute read-only in just a view. If you make an attribute read-only, it will be read-only in all views. If this is what you're looking for, then the perm that would help you is - setVal. You can raise all such questions in the forum link posted by Daniel. That's a more popular forum for DXL related questions with active DXL users.
For now, here's a sample (to be run from within a module) -
string users = ""
AttrDef ad = find(current Module, "HAR_Responsible Domain")
string errMsg = setVal(current Module, ad, read, users)
if(!null errMsg)
print "Error - " errMsg
Note - blank string assigned to users, indicates it is for the default group (Everyone or Everyone Else). If you would like to assign this read-only access to a specific user, you need to specify the Username of that user for the variable users.
If you have any follow-up questions, please post it in the DXL Forum.
Hope that helps.
Cheers,
Sudarshan
For now, here's a sample (to be run from within a module) -
string users = ""
AttrDef ad = find(current Module, "HAR_Responsible Domain")
string errMsg = setVal(current Module, ad, read, users)
if(!null errMsg)
print "Error - " errMsg
Note - blank string assigned to users, indicates it is for the default group (Everyone or Everyone Else). If you would like to assign this read-only access to a specific user, you need to specify the Username of that user for the variable users.
If you have any follow-up questions, please post it in the DXL Forum.
Hope that helps.
Cheers,
Sudarshan
3 other answers
The first function is to set an attribute to read only.
The second function in this post is to set an attribute for read and modify permissions.
The input of both functions is the user which you are trying to set the permissions and the attribute.
Both functions can be improved to check if the module is in Exclusive Edit and if not to switch to exclusive edit mode.
Both functions can be improved to check if the user running these functions has the permissions to set permissions to other users.
------------------------
void setUserReadPermissions(string user, string attributeField)
{
AttrDef ad
string userInput
Object obj = current
Module m = current
ad = find(current, attributeField)
for ad in m do {
setDef(m, ad, read, user)
setVal(m, ad, read, user)
set(obj, read, user)
synchExplorer(m)
refreshExplorer(m)
refresh(m)
}
print " Read Only permissions were attributed to " user "for the attribute" attributeField ". \n"
}
------------------------------------------------------------------------------------
void setUserModifyPermissions(string user, string attributeField)
{
AttrDef ad
string userInput
Object obj = current
Module m = current
ad = find(current, attributeField)
for ad in m do {
setDef(m, ad, read|modify, user)
setVal(m, ad, read|modify, user)
set(obj, read|modify, user)
synchExplorer(m)
refreshExplorer(m)
refresh(m)
}
print " Modify permissions were attributed to " user "for the attribute" attributeField ". \n"
}