Action in a Flow when using the data pill returning a decimal number when it should not
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2024 10:58 AM
Artifacts involved: Flow and a Action which I built for the flow
The flow is pretty basic so I am not going to spend a bunch of time discussing it here. For the flow you can build a run once trigger on a schedule timer just to have something there. Then add the Action then add an email step to use the count from the action to populate the body.
The Problem:
I have an Action which I build that takes the sys_id of the user and runs that through a script that get's the count of active tasks in the task table. When I run test this in the action I am getting the expected number of record count returned. The count is returning the number as a string and is showing the correct results.
When I put this action into the flow and call it, I get the same number returned. I then want to take the count data pill that it produces and put that into an email in the body. When I do that it's taking the number and converting it into a decimal number. Example : Action is returning 71 and Email step in Flow is converting it to 71.0
Question: How can I get it to return just the number without the decimal point
Action Setup:
Inputs:
Script Step:
Script:
(function execute(inputs, outputs) {
//Get user id as input
var userID = inputs.sysid;
//Query for the user tasks
var taskGR = new GlideRecord('task');
taskGR.addQuery('assigned_to', userID);
taskGR.addQuery('active', true);
taskGR.query();
//Set Counter to 0;
var taskCount = 0;
//Loop through records
while (taskGR.next()){
taskCount++; //add to count
}
//Set output to the count
var taskCountConverted = parseInt(taskCount, 10); // Converts to integer
outputs.count = taskCountConverted;
})(inputs, outputs);
Output Variable
Outputs:
Here is what I'm getting returned in the email body:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2024 12:03 PM
Sorry, why do you need this line?
var taskCountConverted = parseInt(taskCount, 10); // Converts to integer
What happens if you just return taskCount?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2024 12:40 PM
Someone suggested converting it to a Int so I tried it. Actually it doesn't make any difference, I have tried both ways
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2024 12:35 AM - edited 11-08-2024 12:35 AM
Hi @Community Alums ,
Your count variable is a string as you configured in the Action output.
Can you just try set the taskCountConverted variable as String as shown below,
var taskCountConverted = String(taskCount);
If this address your question, please mark this response correct by clicking on Accept as Solution and/or Kudos.
You may mark this helpful as well if it helps you.
Thanks,
Animesh Das