Skip to main content
Solved

How to count the number of roles a user is assigned to using FME and the REST API?

  • November 30, 2022
  • 1 reply
  • 39 views

mgg_beca
Supporter
Forum|alt.badge.img+16

Hi there, I am trying to use FME to automate some user management for FME Server. Specifically I would like to schedule a workspace to remove any Azure users that are not members of a role. I have worked out how to list the users and get their roles, but I can't work out how to go from this json array: ["user:admin","fmeadmin","fmesuperuser"] to the integer value 2.

 

Can anyone please help me drop the "user:..." part from the array and count the number of items that are left over?

 

Thanks!

Marc

Best answer by mgg_beca

Nevermind, I adapted the answer from here: https://community.safe.com/s/question/0D54Q000080hL8CSAU/count-elements-in-json-array

 

changing it to: jn:size(fme:get-json-attribute("user_roles_json"))

 

Then I can just subtract 1 from the value to remove the "user:..." part which is always present.

 

Easy. Thanks @Takashi Iijima​ 

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

1 reply

mgg_beca
Supporter
Forum|alt.badge.img+16
  • Author
  • Supporter
  • 81 replies
  • Best Answer
  • November 30, 2022

Nevermind, I adapted the answer from here: https://community.safe.com/s/question/0D54Q000080hL8CSAU/count-elements-in-json-array

 

changing it to: jn:size(fme:get-json-attribute("user_roles_json"))

 

Then I can just subtract 1 from the value to remove the "user:..." part which is always present.

 

Easy. Thanks @Takashi Iijima​