The CreatorCon Call for Content is officially open! Get started here.

Display Checkbox label when true in Description on catalog task

Brookie
Tera Contributor

My scripting knowledge is scant at best but I need help.

 

I have a Catalog Request with these checkboxes.

Brookie_0-1665121324916.png

I want the ones that are check to show in the description of the task. However when I use the data pill picker because it's only true/false it only displays true or false.

My current work around is to manually write each checkbox label out and then use the data pill picker to mark them as true or false

Brookie_1-1665121535923.png

 

As you can see it looks pretty clunky.

Is there a way to make it so that only if checkbox is true then just the label for the checkbox displays?

I have tried for 8 hours and I'm at my wit's end.

I don't know if I should be using this function in flow designer

Brookie_2-1665121630898.png

or maybe using the catalog client script

Brookie_3-1665121720670.png

If anyone could help I would be so grateful because I've invested 8 hours and I can't get anything to work.

Any help would be most welcome

 

 

1 ACCEPTED SOLUTION

Soeren Maucher
Mega Sage

If you want to go for a scripted solution, I would suggest creating a small script in the “Update Record” Action in the Flow Designer. This script will run server side in contrast to the client script on the Catalog Item (small performance and security implications).

 

4.png

 

 

var description = "";
var option_a = fd_data.trigger.request_item.variables.option_a;
var option_b = fd_data.trigger.request_item.variables.option_b;
var option_c = fd_data.trigger.request_item.variables.option_c;

if (option_a=="true"){
    description +=fd_data.trigger.request_item.variables.option_a.getLabel()+"\n";
}
if (option_b=="true"){
    description +=fd_data.trigger.request_item.variables.option_b.getLabel()+"\n";
}
if (option_c=="true"){
    description +=fd_data.trigger.request_item.variables.option_c.getLabel();
}
return description;


I hope this helped! 
Greetings, 
Sören

View solution in original post

6 REPLIES 6

Soeren Maucher
Mega Sage

Hello,

if you don’t feel comfortable with scripting and want to avoid it you could even build an if else logic in the flow and add your labels to the description. For example: If Option A is true add a certain (hard coded String). The same for Option B and C.
This will definitely become quite big depending on the number of options and the String/Text will be hard coded, but would be a potential “low code” solution.

1.png
2.png
3.png


I hope that helped!
Greetings,
Sören

Soeren Maucher
Mega Sage

If you want to go for a scripted solution, I would suggest creating a small script in the “Update Record” Action in the Flow Designer. This script will run server side in contrast to the client script on the Catalog Item (small performance and security implications).

 

4.png

 

 

var description = "";
var option_a = fd_data.trigger.request_item.variables.option_a;
var option_b = fd_data.trigger.request_item.variables.option_b;
var option_c = fd_data.trigger.request_item.variables.option_c;

if (option_a=="true"){
    description +=fd_data.trigger.request_item.variables.option_a.getLabel()+"\n";
}
if (option_b=="true"){
    description +=fd_data.trigger.request_item.variables.option_b.getLabel()+"\n";
}
if (option_c=="true"){
    description +=fd_data.trigger.request_item.variables.option_c.getLabel();
}
return description;


I hope this helped! 
Greetings, 
Sören

Hi Soren,

Thanks for getting back so promptly (and apologies for the late reply). This did EXACTLY what I wanted so I was able to use the script and play around with it to get some other bits and bobs in. 

Just wanted to say how much I appreciate you giving me the script so I could study and understand it (and get it working)

Mahendra RC
Mega Sage

Hello @Brookie 

I think you can use something below below on flow designer to populate the checkbox label. You can do this for all your checkbox field.

 

var shortDescription = [];
if (fd_data._1__get_catalog_variables.acrobat) { // IF acrobat is checked then put Adobe Acrobat label in array
    shortDescription.push("Adobe Acrobat");
}
if (fd_data._1__get_catalog_variables.photoshop) { // IF acrobat is checked then put Adobe Acrobat label in array
    shortDescription.push("Adobe Photoshop");
}
return shortDescription.join("\n");

 

OR you can use the below script to get the variable from Requested Item record and populate the Label in short description dynamically

MahendraRC_0-1665127372215.png

 

var shortDescription = [];
    var ritmVariables = fd_data.trigger.request_item.variables;
    for (var variable in ritmVariables) {
        var variableType = ritmVariables[variable].getQuestion().type;
        if (variableType == 7) {
            if (ritmVariables[variable] == "true") {
                shortDescription.push(ritmVariables[variable].getLabel());
            }
        }
    }
return shortDescription.join("\n");