The attribute dimension is a special dimension that is associated with a business dimension. It is useful and powerful for filtering dimension members, processing specific calculations, and doing reporting. Attributes group data through alternative means as opposed to utilizing the existing dimensional rollups.
For a more detailed attribute introduction, check the following previous post.
Background information and challenges
The attributes functionality is great. However, managing the attribute value could be challenging when regular updates or on-the-fly updates are required.
What if we can have a form and use Smart List to update these “tags”? What if we would like to use these Smart List values to update the attribute values? To make this even more fun, after updating the attribute, can a database refresh job get triggered? Would any end-users can process these activities?
The Groovy business rule is able to achieve all these requirements.
Traditional Approach
Before jumping into the groovy rules, let’s take a quick peek at the traditional approach.
For example, there are three cost centers, 1,2, and 3.
Each of the cost centers would get assigned one of the statuses, Active or Closed.
We can surely manually update attributes for each of the cost centers, or update via dimension load file.
This works. But again, if this information needs to update constantly or needs to update by end-users, the traditional way will not work properly.
Groovy Approach – Smart List + Attribute + REST API
Groovy business rules provide a great solution for this. Other than having attributes, we will create a Smart List for Status. The smart list member names do not need to match the attribute member names. But it will be helpful and easier to have similar names.
Now, create a form to have the Status as Smart List. Assign the Groovy business rule to the form and make it run after saving the form.
We will take a look at the Groovy business rules in the next section.
For example, updating the Cost Center 3 status from Active to Closed.
When saving the form, the Groovy business rule will be triggered. The attribute for Cost Center 3 will get updated based on the Smart List changes.
Check the Cost Center 3 attribute. We see it gets updated to Closed.
Sample code
The logic for the Groovy business rule is straightforward. It has the following 6 sections.
- Define dimension, create an object
- Navigate through each edited cell
- From the edited cells, get the dimension member names
- Pass the HSP_ID for the edited cells to get the smart list names for these IDs
- Convert the name to the attribute name. use substring as needed
- Use the saveMember function to update the attribute
The key here is to use the saveMember function to update the attribute.
Here is the Groovy business rule. You can always update the rule based on the specific requirements.
After running the Groovy business rule, use REST API to trigger the database refresh process. For example,
Groovy business rules greatly simplified the updating attribute business rule processes. An application admin or users will be able to update the attributes via the Smart List dropdown on a webform. The database refresh job can be attached to the same rule or as a separate process.
No more manual updates. Groovy rules completed the mission. Hope you enjoy this post.
Were you able to work this out with users or power users? Appears savemember function can be run only by admins…