top of page
OmniStudioFactBg.png
Search

Use ‘Exposed Attributes’ to configure action labels dynamically

  • Writer: Gayathiri Mohan
    Gayathiri Mohan
  • Jul 24, 2023
  • 2 min read

Updated: Jul 27, 2023

With Exposed Attributes, we can dynamically configure action labels, action visibility, and

conditional styling in Flexcard.

Let’s take a look at them below:


1) To configure the action label and text contents dynamically:


‘Exposed Attributes’ allow us to configure the action (button) labels directly from the App Builder or Experience Builder based on the need.


In the below example, an exposed attribute ‘DynamicButtonName’ of type ‘String’ is created with the default value "View record” in the ‘Exposed API’ modal.

ree

In the label of the ‘Action’ properties, the exposed attribute is accessed as {Session.DynamicButtonName}

ree

And another exposed attribute, ‘Content’ of type ‘String’ is created without filling in the default value.

ree

Similarly, the exposed attribute is accessed as {Session.Content} in a text element.

ree

Now activate the flexcard and go to the flexipage.

ree

In the ‘Enter your preferred Navigation term’ field, we can enter any navigation term based on the need to replace the default value ‘View Record’ set for the action label in the UI.


Additionally, for the ‘String type’ exposed attributes, we can also use custom labels in the format "{!$Label.customLabelName}". Here, our custom label name is ‘testLabel’ and it is entered as ‘{!$Label.testLabel}’ in the ‘Content’ field.


Now you can see the modified contents of the Flexcard as below.

  • Action label is displayed as ‘Navigate’.

  • Text element shows the contents of the custom label mentioned.

ree

2) To configure the visibility of an action (button):


With ‘Exposed Attributes’, we can conditionally show or hide an action by configuring it directly from the App Builder or Experience Builder based on the need.


In the below example, an exposed attribute ‘HideButton’ of type ‘Boolean’ is created with the default value "false" in the ‘Exposed API’ modal.

ree

An action (button) with the label ‘View All’ is created, and in the ‘Conditions’ section of the ‘Action Properties’, a condition is added as ‘Session.HideButton = false’.

ree

NOTE: The format for accessing the exposed variable in the ‘Conditions’ section is ‘Session.AttributeName’. We shouldn’t be using “{}” along with Session.AttributeName like we did in the earlier cases.


After activating the flexcard, you can observe that the ‘View All’ button is displayed in the UI.

ree

Now go to the Flexipage, and you can observe that the ‘Do you want to hide the ‘View All’ button?’ checkbox is unchecked by default.

ree

When you check the checkbox and observe the UI, the ‘View All’ button will be hidden.

ree

3) To configure the conditional styling for elements:


Similarly, we can use ‘Exposed Attributes’ to dynamically configure the conditional styling for flexcard elements from the App Builder or Experience Builder.


In the below example, an exposed attribute ‘BorderColor’ of type ‘String’ is created without filling in the default value in the ‘Exposed API’ modal.

ree

Now from the block element’s Style tab, click the ‘Add Conditional Style’ button and add conditions to display different colors based on the ‘exposed attribute’ value.

ree

Here, a conditional style named ‘BlackBorder’ is created with the condition "Session.BorderColor = Black”.


Similarly, conditional styles are created for green and blue color borders as well.

ree

Activate the flexcard and observe that it is displayed with the default ‘gray’ color border in the UI.

ree

Now you can configure the border color as per your needs from the Flexipage.

If the value entered is ‘blue’, then a blue color border is displayed for the block.

ree
ree

Similarly, ‘green’ and ‘black’ color borders are displayed for the block when the respective colors are entered in the Flexipage’s field.

ree
ree


References:




 
 
 

Recent Posts

See All

Comments


OmniStudioFactFooterBg.png
logo.png

OmniStudiofacts helps us to build a Vlocity/OmniStudio Tech Community which focuses on sharing technical skills and experience across the globe.

© 2023 by OmniStudioFacts.

bottom of page