<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Thingworx Remove all permissions in ThingWorx Developers</title>
    <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Thingworx-Remove-all-permissions/m-p/1026628#M70156</link>
    <description>&lt;P&gt;Did you try a snippet I provided? It is five times shorter, and also handles design-time and visibility permissions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you wrote there can be achieved with a oneliner:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Projects[projectName].GetEntities().rows.toArray().filter(row =&amp;gt; row.type === 'Thing').forEach(r =&amp;gt; Things[r.name].SetRunTimePermissionsAsJSON({ permissions: {} }));&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/ Constantine&lt;/P&gt;</description>
    <pubDate>Mon, 28 Jul 2025 09:50:25 GMT</pubDate>
    <dc:creator>Constantine</dc:creator>
    <dc:date>2025-07-28T09:50:25Z</dc:date>
    <item>
      <title>Thingworx Remove all permissions</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Thingworx-Remove-all-permissions/m-p/1026421#M70142</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I use Thingworx version 9.6.2. It seems that the Resources["SecurityServices"].DeleteRunTimePermission first parameter type needs to be "Thing" for example if one is to remove permissions from that thing.&lt;BR /&gt;&lt;BR /&gt;This is the code for a service to remove all permissions that i have to far, however the error message i get is following:&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;Error executing service RemoveAllPermissions. Message :: Invalid Permission Type : [Thing] - See Script Error Log for more details.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The point of the service is to remove all existing permissions added to a thing from a user or group, NOT changing the permissions level like read/write/subscribe etc.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Code:&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV&gt;&lt;P&gt;var projectName = me.ProjectName;&lt;BR /&gt;var projectEntities = Projects[projectName].GetEntities();&lt;BR /&gt;logger.info("all entities in project: " + projectEntities.rows);&lt;BR /&gt;var result = [];&lt;/P&gt;&lt;P&gt;var things = [];&lt;BR /&gt;var userOrUserGroups = [];&lt;/P&gt;&lt;P&gt;// sorting things and nonthings in two seperate lists&lt;BR /&gt;for (var i = 0; i &amp;lt; projectEntities.rows.length; i++) {&lt;BR /&gt;&lt;BR /&gt;var entity = projectEntities.rows[i];&lt;BR /&gt;&lt;BR /&gt;if (entity.type == "Thing"){&lt;BR /&gt;things.push(entity);&lt;BR /&gt;}&lt;BR /&gt;if (entity.type == "User" || entity.type == "Group"){&lt;BR /&gt;userOrUserGroups.push(entity);&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// removing runtime permissions for every user or usergroups for all things&lt;BR /&gt;for (var j = 0; j &amp;lt; things.length; j++){&lt;BR /&gt;for (var k = 0; k &amp;lt; userOrUserGroups.length; k++){&lt;BR /&gt;&lt;BR /&gt;Resources["SecurityServices"].DeleteRunTimePermission({&lt;BR /&gt;type: things[j].type,&lt;BR /&gt;resource: things[j].name,&lt;BR /&gt;principal: userOrUserGroups[k].name,&lt;BR /&gt;principalType: userOrUserGroups[k].type&lt;BR /&gt;});&lt;BR /&gt;result.push(userOrUserGroups[k]);&lt;BR /&gt;logger.warn("Deleted all permissions for Thing: " + things[j]);&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jul 2025 12:50:06 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Thingworx-Remove-all-permissions/m-p/1026421#M70142</guid>
      <dc:creator>PK_13806485</dc:creator>
      <dc:date>2025-07-25T12:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: Thingworx Remove all permissions</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Thingworx-Remove-all-permissions/m-p/1026597#M70144</link>
      <description>&lt;P&gt;How do you know the first parameter is the type of the entity?&lt;/P&gt;
&lt;P&gt;The error message says that where you put in the entity type, it expects really the &lt;EM&gt;permission&lt;/EM&gt; type:&lt;/P&gt;
&lt;P&gt;Invalid Permission Type : [Thing]&lt;/P&gt;
&lt;P&gt;What I think this does is it deletes the runtime permission on the Resource&amp;nbsp;SecurityServices itself, not on the thing you want. You need to run the service on the entity itself, I guess.&lt;/P&gt;
&lt;P&gt;valid permission type values can be found here:&amp;nbsp;&lt;A href="https://support.ptc.com/help/thingworx_hc/javadoc/com/thingworx/security/permissions/PermissionTypes.html" target="_blank"&gt;https://support.ptc.com/help/thingworx_hc/javadoc/com/thingworx/security/permissions/PermissionTypes.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jul 2025 07:28:07 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Thingworx-Remove-all-permissions/m-p/1026597#M70144</guid>
      <dc:creator>Rocko</dc:creator>
      <dc:date>2025-07-28T07:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: Thingworx Remove all permissions</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Thingworx-Remove-all-permissions/m-p/1026610#M70145</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Services "DeleteRunTimePermission" and "DeleteDesignTimePermission" are defined on all entities, and "type" parameter is for the &lt;EM&gt;permission&lt;/EM&gt; type, not entity type.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to simply remove everything from an individual Thing, the easiest would be like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;for (var i = 0; i &amp;lt; projectEntities.rows.length; i++) {
    let row = projectEntities.rows[i];
    if (row.type === "Thing") {
        let thing = Things[row.name];
        thing.SetRunTimePermissionsAsJSON({ permissions: {} });
        thing.SetDesignTimePermissionsAsJSON({ permissions: {} });
        thing.SetVisibilityPermissionsAsJSON({ permissions: {} });
    }
}
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just to make it clear -- there will be still &lt;EM&gt;some&lt;/EM&gt; permissions, which those things inherit from their parent Thing Template and from Collection level. Also there's the Owner semantics, which you need to keep in mind. So if I may ask -- why do you want to do it? There might be another, better way to achieve what you need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/ Constantine&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jul 2025 07:47:23 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Thingworx-Remove-all-permissions/m-p/1026610#M70145</guid>
      <dc:creator>Constantine</dc:creator>
      <dc:date>2025-07-28T07:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: Thingworx Remove all permissions</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Thingworx-Remove-all-permissions/m-p/1026626#M70155</link>
      <description>&lt;P&gt;This code seemed to fix the problem:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Skärmbild 2025-07-28 114138.png" style="width: 739px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/126200iA04C2589A0F1E6DB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Skärmbild 2025-07-28 114138.png" alt="Skärmbild 2025-07-28 114138.png" /&gt;&lt;/span&gt;&lt;BR /&gt;The reason for this service is to get a form of "clean slate" when you can take in a project, clear all existing permissions of all things in the project so you can start fresh, if a situation like that would appear.&lt;BR /&gt;// PK&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jul 2025 09:42:19 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Thingworx-Remove-all-permissions/m-p/1026626#M70155</guid>
      <dc:creator>PK_13806485</dc:creator>
      <dc:date>2025-07-28T09:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: Thingworx Remove all permissions</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Thingworx-Remove-all-permissions/m-p/1026628#M70156</link>
      <description>&lt;P&gt;Did you try a snippet I provided? It is five times shorter, and also handles design-time and visibility permissions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you wrote there can be achieved with a oneliner:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Projects[projectName].GetEntities().rows.toArray().filter(row =&amp;gt; row.type === 'Thing').forEach(r =&amp;gt; Things[r.name].SetRunTimePermissionsAsJSON({ permissions: {} }));&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/ Constantine&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jul 2025 09:50:25 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Thingworx-Remove-all-permissions/m-p/1026628#M70156</guid>
      <dc:creator>Constantine</dc:creator>
      <dc:date>2025-07-28T09:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: Thingworx Remove all permissions</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Thingworx-Remove-all-permissions/m-p/1026629#M70157</link>
      <description>&lt;P&gt;Hello Constantine,&lt;BR /&gt;&lt;BR /&gt;See my reply as solution. Thank you, do your code that you illustrated achieve the same result as mine?&lt;BR /&gt;&lt;BR /&gt;// PK&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jul 2025 09:44:22 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Thingworx-Remove-all-permissions/m-p/1026629#M70157</guid>
      <dc:creator>PK_13806485</dc:creator>
      <dc:date>2025-07-28T09:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: Thingworx Remove all permissions</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Thingworx-Remove-all-permissions/m-p/1026630#M70158</link>
      <description>&lt;P&gt;Yup.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jul 2025 09:54:06 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Thingworx-Remove-all-permissions/m-p/1026630#M70158</guid>
      <dc:creator>Constantine</dc:creator>
      <dc:date>2025-07-28T09:54:06Z</dc:date>
    </item>
    <item>
      <title>Re: Thingworx Remove all permissions</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Thingworx-Remove-all-permissions/m-p/1026666#M70159</link>
      <description>&lt;P&gt;I tried it and it worked great, very simple solution, well done and thank you ^^&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jul 2025 11:59:45 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Thingworx-Remove-all-permissions/m-p/1026666#M70159</guid>
      <dc:creator>PK_13806485</dc:creator>
      <dc:date>2025-07-28T11:59:45Z</dc:date>
    </item>
  </channel>
</rss>

