UPDATE! The community will be go into read-only on April 19, 8am Pacific in preparation for migration on April 21. Read more.
UPDATE! The community will be go into read-only on April 19, 8am Pacific in preparation for migration on April 21.Read more.
Captain
Captain
393 views

Attributes with JSON Array

Jump to solution

Hi

 

We have some users where the description attribute contains a JSON array. Like this ""description":["Role1","Role2"]". This causes an error when collecting. IG compains about multiple values for a single valued field.

So I am trying to write a transformation script to fix it. I have the following code:

function hasJsonStructure(str) {
if (typeof str !== 'string') return false;
try {
const result = JSON.parse(str);
const type = Object.prototype.toString.call(result);
return type === '[object Object]' || type === '[object Array]';
} catch (err) {
return false;
}
}


if (hasJsonStructure(inputValue)) {
outputValue=''
} else {
outputValue=inputValue
}

 

if I run it with nodejs on the command line it works, but IG throws the following error:

Data collection response 'STATUS' for service eDirectoryAccountTemplate-1616593789547-gromitid-3: Transformation Script Error for field 'description': [<eval>:4:8 Expected an operand but found const const result = JSON.parse(str); ^ in <eval> at line number 4 at column number 8]

 

Any ideas why it works with nodejs, but not IG ?

 

1 Solution

Accepted Solutions
Micro Focus Expert
Micro Focus Expert

Try var instead of const.

The nodejs you are using does probably support a newer ECMAScript language version than IG.

Note: Please use "code sample" function in the editor if you post code. The markup makes it so much more easy to read.

function hasJsonStructure(str) {
    if (typeof str !== 'string') return false;
    try {
        const result = JSON.parse(str);
        const type = Object.prototype.toString.call(result);
        return type === '[object Object]' || type === '[object Array]';
    } catch (err) {
        return false;
    }
}


if (hasJsonStructure(inputValue)) {
    outputValue = ''
} else {
    outputValue = inputValue
}

 

 

--
Norbert

View solution in original post

6 Replies
Micro Focus Expert
Micro Focus Expert
Greetings,
    What is the exact version of ID Gov that you are using?
 
Sincerely,
Steven Williams
Principal Enterprise Architect
Micro Focus
0 Likes
Micro Focus Expert
Micro Focus Expert
Greetings,
   
1) You should try your code fist in the Transform Tester tool as compared to utilizing either a Full Collect or Test collect.  Are you using this tool?
 
2) What ultimately do you want the result to look like within ID Gov? Please provide an example 
 
3) Did you review the examples within the following technical references from our Documentation Page:
 
 
 
 
Sincerely,
Steven Williams
Principal Enterprise Architect
Micro Focus
0 Likes
Micro Focus Expert
Micro Focus Expert

Try var instead of const.

The nodejs you are using does probably support a newer ECMAScript language version than IG.

Note: Please use "code sample" function in the editor if you post code. The markup makes it so much more easy to read.

function hasJsonStructure(str) {
    if (typeof str !== 'string') return false;
    try {
        const result = JSON.parse(str);
        const type = Object.prototype.toString.call(result);
        return type === '[object Object]' || type === '[object Array]';
    } catch (err) {
        return false;
    }
}


if (hasJsonStructure(inputValue)) {
    outputValue = ''
} else {
    outputValue = inputValue
}

 

 

--
Norbert

View solution in original post

Captain
Captain

@klasenThanx. Converting the const to var fixed the issue

@stevewdjI don't know about the Transform Tester tool. I cannot find any reference to it in the docs

Knowledge Partner Knowledge Partner
Knowledge Partner

Why I wrote about it in detail.  Too bad the docs refuse to link to good articles that cover a topic that for some reason they do not.

 

https://community.microfocus.com/t5/IGA-Tips-Information/Getting-Started-with-Identity-Governance-Part-4/ta-p/1771623

 

Knowledge Partner Knowledge Partner
Knowledge Partner

The part I refered to in that linked article is the Transform Tester. As Steve notes, a very useful tool for testing.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.