ftos.data.isInAudience
Checks if a record is associated with an audience.
IMPORTANT!
Starting with v24.3.0, this is renamed from isInAudience to ftos.data.isInAudience.
Starting with v24.3.0, this is renamed from isInAudience to ftos.data.isInAudience.
This is a data service method for business service components.
Syntax
Copy
function ftos.data.isInAudience(audienceName : string, entityId : string): boolean;
| Parameter | Type | Description |
|---|---|---|
audienceName
|
string | Name of the audience. |
entityId
|
string | Record ID of the target entity instance that you wish to check whether it is associated with the audience. |
Return Value
Returns True if the record is associated with the audience and False otherwise.
Examples
In this example:
- We check if the current record (ftos. ftos.context.id) is associated with the newsletterSubscribers audience.
- If so, we display the "User is in newsletter audience." message in the user interface. Otherwise, we display "User is not in newsletter audience.".
For more details on how to display messages in the user interface, see ftos.context.response.setMessage.
Copy
if (ftos.data.isInAudience('newsletterSubscribers', ftos.context.id)){
ftos.context.response.setMessage('User is in newsletter audience.')
}else{
ftos.context.response.setMessage('User is not in newsletter audience.')
}