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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

How to programmatically add visibility permissions?

jdaniel
1-Visitor

How to programmatically add visibility permissions?

How do you programmatically refer to a sub-organization in the following example?  I want to add a sub-organization to the visibility permissions of an existing Thing.  The service snippet looks like the following but there's no information on the requirements or formatting of the "principal" and "principalType" strings.

var params = {

  principal: mySubOrganization,

  principalType: "Organization"

};

Things["myThing"].AddVisibilityPermission(params);

If I have an organization named “Org” and that organization contains a sub-organization called “Sub”, what should I enter for the "principal" string?  Is this the proper form of the property?

mySubOrganizaiton = "Org:Sub";


Next, what is the correct string to use for the "principalType"?  I've tried "Organization", "OrganizationUnit", and "Organization Unit" without success.


Lastly, where is this information documented?


Thanks -

ACCEPTED SOLUTION

Accepted Solutions

You are right with mySubOrganization = "Org:Sub" that's principal, por principalType you should write "OrganizationalUnit"

Documented? I don't remember where I found it or I may did just try/fail.

Documentacion:

View solution in original post

5 REPLIES 5

You are right with mySubOrganization = "Org:Sub" that's principal, por principalType you should write "OrganizationalUnit"

Documented? I don't remember where I found it or I may did just try/fail.

Documentacion:

Hi Coll,

It is working cool.

Thanks.

vmihai
12-Amethyst
(To:jdaniel)

Hi Joe,

You can see what options exist for the parameters expected in a given service through the service definitions of that thing.

In your case this is the link where you would find the possible values for the AddVisibilityPermission service parameters

http://127.0.0.1:8787/Thingworx/Organizations/Your_Org_Name/ServiceDefinitions/AddVisibilityPermission

adrianpet
12-Amethyst
(To:jdaniel)

Hi,

     This is an example of an Visibility Permission with the help of REST:

instanceURL+"/Thingworx/DataShapes/DataShape1/Services/AddVisibilityPermission?principal="+Organization_Name +"&principalType=Organization&method=post" /* STRING */,

where instanceURL is an input into your service where you can set your hostname(for ex: http://localhost)

and Organization_Name is another input where you can set the organization for which you want to add the Visibility Permission on this entity(in this case the DataShape1 Data Shape), you can either put an input or you have just one organization and don't want to use this for any other visibility permissions you can just type the name of the organization(for ex, if you want to to grant Visibility Permissions on local instance for DataShape1 for an Test_Org organization the request will be: "http://localhost/Thingworx/DataShapes/DataShape1/Services/AddVisibilityPermission?principal=Test_Org&principalType=Organization&method=post" /* STRING */,

Hope this helped,

Adrian

jdaniel
1-Visitor
(To:jdaniel)

Thanks.  The "principalType" must be set to "OrganizationalUnit".

Using "Organization Unit", as the service definition states, will produce an exception.  The service definition information is wrong.

Announcements


Top Tags