Skip to main content
15-Moonstone
April 29, 2021
Solved

How to AddRuntimePermission for PlatformSubsystem & CurrentSessionInfo through service

  • April 29, 2021
  • 1 reply
  • 2353 views

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

 

Best answer by sabharees

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 🙂

1 reply

17-Peridot
April 29, 2021

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

sabharees15-MoonstoneAuthor
15-Moonstone
April 29, 2021

Hi @yhan,

 

Is there any way to achieve this ?

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

17-Peridot
April 29, 2021

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