Parse JSON In Canvas App using Regex

Set(
customEntityData,

customentity,

)

);

ClearCollect(

customEntityWithSecurityRoles,

AddColumns(

customEntityData,

"EntityName",

'Entity Name',

"SecurityRoles",

MatchAll(

'Security Roles (JSON)',

"\{""id"":""(?<id>[^""]*)"",""name"":""(?<name>[^""]*)"

)

)

);

In the above query e have used the Regex as below:
"\{""id"":""(?<id>[^""]*)"",""name"":""(?<name>[^""]*)"
//get logged in user

Set(currntUser,First(Filter(Users,'User Name'=User().Email)));

//get logged in users security roles

ClearCollect(userRoles,AddColumns(currntUser.'Security Roles (systemuserroles_association)',"Id",Upper(Role)));

//get security roles from json Field

ClearCollect(requiredRoles,Split(Mid(Concat(ThisItem.SecurityRoles,","&id),2,1000),","));

//apply forAll on requiredRoles collection

Clear(roleCollection);

ForAll(requiredRoles As _roles,Collect(roleCollection,If(CountRows(Filter(userRoles,Id=_roles.Result))>0, true , false )));

//If get same security id collection count greater than 0 then navigate to entity screen,else show error screen

If(CountRows(Filter(roleCollection As _roleCollection,_roleCollection.Value= true ))>0,Navigate(entity_screen),Navigate(Error_screen));

Conclusion:

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store