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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

How to AddRuntimePermission for PlatformSubsystem & CurrentSessionInfo through service

sabharees
13-Aquamarine

How to AddRuntimePermission for PlatformSubsystem & CurrentSessionInfo through service

Hi, 

 

Currently I  am  trying to add runtime permissions for PlatformSubsystem , CurrentSessionInfo & RuntimeLocalizationFunctions through service. I am only able to add permissions for  "ServiceInvoke" but if I try to add permissions for  "PropertyRead" , "PropertyWrite", "EventInvoke" , "EventSubscribe"

 

I am getting error message for event perms.  = > Error executing service test1. Message :: This entity does not support event permissions - See Script Error Log for more details.

 

 for property perms. = > Error executing service test1. Message :: This entity does not support property permissions - See Script Error Log for more details.

 

 

sabhz_0-1619689854251.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
sabharees
13-Aquamarine
(To:yhan)

Hi @yhan,

 

Thanks for your response, It is really helpful for me !! 

But due to some business reasons, we decided to add permissions for propertyRead, write, event invoke, subscribe... 

 

So, I created a workaround using SetRunTimePermissionsAsJSON. First, I am getting GetRunTimePermissionsAsJSON as JSON and adding(using this method to avoid loss of previously assigned permissions) my required permissions using push method.

 

Sample code for this :

 

var json = Resources["RuntimeLocalizationFunctions"].GetRunTimePermissionsAsJSON();

json["permissions"].push({
"PropertyRead": [{
"isPermitted": true,
"name": dashboardUserGroupName, //usergroup
"type": "Group" 
}],
"resourceName": "*"
}, {
"PropertyWrite": [{
"isPermitted": true,
"name": dashboardUserGroupName,
"type": "Group"
}],
"resourceName": "*"
}, {
"ServiceInvoke": [{
"isPermitted": true,
"name": dashboardUserGroupName,
"type": "Group"
}],
"resourceName": "*"
}, {
"EventInvoke": [{
"isPermitted": false,
"name": dashboardUserGroupName,
"type": "Group"
}],
"resourceName": "*"
}, {
"EventSubscribe": [{
"isPermitted": false,
"name": dashboardUserGroupName,
"type": "Group"
}],
"resourceName": "*"
});


result = Resources["RuntimeLocalizationFunctions"].SetRunTimePermissionsAsJSON({
 permissions: json /* JSON */
});

 

Hope, this will be helpful for someone, sometime

View solution in original post

5 REPLIES 5
yhan
17-Peridot
(To:sabharees)

Hi @sabharees,

 

The error is because you set the type as "EventInvoke",  we can not define events in PlatformSubsystem or RuntimeLocalizationFunctions resource, so there isn't the type as EventInvoke when executing AddRunTimePermission on the two resources.

 

Thanks,

/Yoyo

sabharees
13-Aquamarine
(To:yhan)

Hi @yhan,

 

Is there any way to achieve this ?

because I need to set PropertyRead, PropertyWrite, EventInvoke & EventSubscribe through service !! 

yhan
17-Peridot
(To:sabharees)

Hi @sabharees,

 

I cannot understand why you need to set EventInvoke permission on PlatformSubsystem & CurrentSessionInfo. Is any other entities will implement the two resources? We can set it on thing template/thing services which we always use in a mashup. 

Could you explain more about your business scenario?

 

Thanks,

/Yoyo

 

yhan
17-Peridot
(To:sabharees)

Hi @sabharees,

 

Got your message. I think I get your business requirement.

For PlatformSubsystem and CurrentSessionInfo resources, it just needs to add ServiceInvoke and visibility for the group. That's enough because there aren't any properties or events of the two resources so you needn't set runtime permission on them for users/group.

 

For thing or thing template, you can set PropertyRead, PropertyWrite, EventInvoke & EventSubscribe through service because users need these permissions to read/write properties and invoke/subscribe event on things or thing templates.

Hope the above can answer your questions.

 

Thanks,

/Yoyo

sabharees
13-Aquamarine
(To:yhan)

Hi @yhan,

 

Thanks for your response, It is really helpful for me !! 

But due to some business reasons, we decided to add permissions for propertyRead, write, event invoke, subscribe... 

 

So, I created a workaround using SetRunTimePermissionsAsJSON. First, I am getting GetRunTimePermissionsAsJSON as JSON and adding(using this method to avoid loss of previously assigned permissions) my required permissions using push method.

 

Sample code for this :

 

var json = Resources["RuntimeLocalizationFunctions"].GetRunTimePermissionsAsJSON();

json["permissions"].push({
"PropertyRead": [{
"isPermitted": true,
"name": dashboardUserGroupName, //usergroup
"type": "Group" 
}],
"resourceName": "*"
}, {
"PropertyWrite": [{
"isPermitted": true,
"name": dashboardUserGroupName,
"type": "Group"
}],
"resourceName": "*"
}, {
"ServiceInvoke": [{
"isPermitted": true,
"name": dashboardUserGroupName,
"type": "Group"
}],
"resourceName": "*"
}, {
"EventInvoke": [{
"isPermitted": false,
"name": dashboardUserGroupName,
"type": "Group"
}],
"resourceName": "*"
}, {
"EventSubscribe": [{
"isPermitted": false,
"name": dashboardUserGroupName,
"type": "Group"
}],
"resourceName": "*"
});


result = Resources["RuntimeLocalizationFunctions"].SetRunTimePermissionsAsJSON({
 permissions: json /* JSON */
});

 

Hope, this will be helpful for someone, sometime

Top Tags