Is it possible to build an Audience via a Script?

G Phoenix
Giga Guru

I have an idea to create an audience (in Content Publishing) based off of logic from the sys_user table (ie, if a user has a specified date in one field I want to create notifications and banners for their specific managers).  I have tried to use the internal Audience logic to create this but have yet to succeed.  I would like to build the audience via a script so that I can include the specific logic in the script and have the script run everyday so that the audience is changed daily.  Is this possible or am I just barking up the wrong tree?

 

Example:  If User's prim_location is 'Florida', then I want to show a banner for that employee's manager.

11 REPLIES 11

Ravi9
ServiceNow Employee
ServiceNow Employee

right , not a content publish mgmt expert here ! but i checked the audience table and there is no script option available , hence wondering when u said u want to generate dynamically - is that what you were hoping ? instead of having filters you want to have a script option ? sorry if i misunderstood ur need ! 

No, you understand what I'm trying to accomplish.

 

We get a lot of demand (from higher management) for banners that have shifting audiences.  I was hoping to solve this issue via a script, but so far that doesn't appear to be an option.

Ravi9
ServiceNow Employee
ServiceNow Employee

so i found something ! not sure if it will work out 

there is a util sn_cd.cd_Audience - script include 

the audience table is used pretty heavily here 

on paper if you can find the right function , maybe add a separate "audience type" altogether with a new script field on audience table ? and tweak the util code such that for ur "type" it executes the code 

lemme know if it makes sense !

You can use groups to aggregate your target audience. Then, set the group in your user criteria and use it for your content experience audience.

ChrisBurks
Mega Sage

I believe that Content Publishing Audience can also use User Criteria by changing the Audience type to this option.

User Criteria can be built with a script if the "Advanced" checkbox is selected when creating the criteria.

 

So my thought is:

1) Build a User Criteria using the Advanced option with your script.

2) In the Content Publishing Audience record set the Audience type to User Criteria

3) In the User Criteria that appears select the User Criteria built above in number 1.