Using flow activity or function to add Cost Fields.

EricG
Kilo Sage

I'm stuck on a flow i've created.

 

The basic function is to allow users to select multiple Hardware Assets at one time.

I can update the Asset and associated CI with no issues.

 

Now, I need to add all costs associated to each Asset and put that in the Flow Variable, so that i can update the Catalog variable for reporting.

 

I have a client script for a similar form that can do this.

	var newPrice = unit.replace('$', '');
	var existPrice = g_form.getValue("device_total_cost").replace('$', '');
	
	var extendPrice = "";
	extendPrice = Number(existPrice) + Number(newPrice);
	//alert("Not sure why values are not adding. Unit = "+unit+", New Price = "+newPrice+", Exisitng Price = "+existPrice+" for total of "+extendPrice);
	g_form.setValue('device_total_cost',"$"+parsefloat(extendPrice).toFixed(2));

 

I'm trying to avoid creating a custom Flow Action and thought to use the functions available to the Pill Record.

It's not working.

Code is 

var origCst = fd_data._8__look_up_hardware_record.cost;//.replace("$","");
var origFVCst = fd_data.flow_var.cpu_ttl_cost;//.replace("$","");
var newTTL = origCst+origFVCst;

return "$"+parseFloat(newTTL).toFixed(2);

but i'm getting this error

EricG_0-1737134653132.png

 

If i just put the pill records together in the Flow Logic activity

EricG_1-1737134738332.png

I get this.  

 

EricG_4-1737135198179.png

while this is acceptable for Serial numbers, the costs don't make sense.

 

Any suggestions on a solution.

 

 

1 ACCEPTED SOLUTION

Can you try parseInt or parseFloat with mentioning base 10? It can be done. Like below if that works.

var a = '123';

var b = parseInt(a, 10);

 

View solution in original post

8 REPLIES 8

Hi @EricG2 ,

 

Ok. Have you tried changing the script as shown and highlighted below?

var origCst = fd_data._8__look_up_hardware_record.record.cost

 

May be that '.record' is missing there.

 

If this address your question, please don't forget to 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

Getting closer, thanks.

 

It is still functioning as a concatenation.

I put in a gs.info to see what i'm getting in the loop.

 

1. the costs are 1288.72 and the total is and ttl is 1288.72

2. the costs are 1331.52 and the total is 1288.72 and ttl is 1331.521288.72

3. the costs are 0 and the total is 1331.52 and ttl is 01331.52

 

I've tried to convert the Cost and TTl Cost using parseInt() or number(), then the results are NaN.

 

 

Can you try parseInt or parseFloat with mentioning base 10? It can be done. Like below if that works.

var a = '123';

var b = parseInt(a, 10);

 

That work @Animesh Das2 .  Thanks.  I'm not sure why my other attempts at parseInt() returned NaN.  But it's working now.  as is parseFloat().toFixed(2).