Expand my Community achievements bar.

SOLVED

Target page params as array

Avatar

Level 6

I have this targetPageParamsAll() in the AEM page which would return the user groups as an array.

targetPageParamsAll = function() { 

		 var userGroups = "everyone,test1,test2,beta1";
		 var userGroups = userGroups.split(",");

		  return { 
		    "userGroups": userGroups
		  }
	}; 

 

Attaching a screenshot on the available mbox parameter w.r.t userGroups below,

 

pscript.png

My requirement is to check whether the user belongs to a certain group and return that group name from the script. With the above highlighted, would I need to check each of these individual params(ranging from 0 to 16) and return for true cases.

Is it possible I can get the userGroup as an array instead(var userGroups = mbox.param('userGroups');) and check whether the user belongs to a particular group(eg:beta1)? Some recommendations on this would be appreciated. Thanks!

1 Accepted Solution

Avatar

Correct answer by
Level 4

I suppose you could try passing the array as a stringified object, such as:

   return { userGroups: JSON.stringify(userGroups) };

 

And then parse it as an array in the profile script:

var userGroups = JSON.parse(mbox.param('userGroups'));

 

View solution in original post

2 Replies

Avatar

Correct answer by
Level 4

I suppose you could try passing the array as a stringified object, such as:

   return { userGroups: JSON.stringify(userGroups) };

 

And then parse it as an array in the profile script:

var userGroups = JSON.parse(mbox.param('userGroups'));

 

Avatar

Employee Advisor

@jgrubbs The similar approach actually worked for me, but I need it as a list to create an exclusion in recommendation -

khushbook25_0-1646223649947.png

Will it work for my use case? I have posted it separately over here -

https://experienceleaguecommunities.adobe.com/t5/adobe-target-questions/can-we-pass-multiple-values-...

Any help would be appreciated, thanks!