Dynamically assign text value in a calc script

This blog post is similar to the On-Prem one. We did see how to create text value from the rule dynamically, it’s now time to see how this can be done on Cloud.

When you are on Planning Cloud, you do have more options than on-premises. You can solve this in a few different ways.

What we are trying to do is generate text value from a rule, if you are looking for an option where the user is entering text, you can always use StringAsNumber variable and prompt them for the text.

This method is only for cases where you are using the text from a different variable other than StringAsNumber, or let’s say you are concatenating strings. (this was the case with the other blog post too)

As I was mentioning, Cloud provides you multiple options to solve this issue.

You can use a hierarchy driven Smart List and then use SLAliases trick. Now that PBCS supports @ALIAS function, you don’t need to follow the method I wrote almost 3 years back.

I can create my FromEntity as a smart list (create a hierarchy-driven smart list and assign that one), and then prompt the user to select the entity.

When they make the selection, I can then strip out HSP_ID_ and get the number to set the value for the Hierarchy-driven smart list.

The command will look like Plan=@CalcMgrDoubleFromString(@SUBSTRING(@ALIAS(@NAME({FromDepartment}),”SLAliases”),7));

You can use groovy to set the text value. What we are going to look at is a straightforward calc rule.

It uses a planning expression called PlanningFunctions.getIdForString.

Before I ran the rule, I did take an export of Text Values to make sure that the rule is creating an entry.

I don’t have any text entries for this application so far.

All I did is to run the rule and select a value for the prompt.

That is the result we are expecting. Let’s look at the text values.xml file again.

Well, I did run it multiple times, and that’s why you see those entries there.

Calculation Manager rule


That’s it, one line of code!

You can now perform many string operations using the on-premises and this blog post. I’ve seen multiple requests where people were looking to concatenate string and assign it to a member, here you go, you now have a way to do it.

Leave a comment

Your email address will not be published. Required fields are marked *