Set value in a currency field on client script

Osvald
Giga Contributor

Hi all,

I'm trying to set a value in a currency field through client script:

find_real_file.png

This is my code: 

=============================================

function onLoad() {
  //Type appropriate comment here, and begin script below
  var vls_pj = 0.0;
  var total;
  var valor = g_form.getDecimalValue('u_valor_liquido_impostos');
  var sc = g_form.getDecimalValue('work_cost');
  var pj = new GlideRecord('tsp1_project');
  pj.addQuery('primary_program',g_form.getUniqueValue());
  pj.query();

  while(pj.next()){
    vls_pj = vls_pj + parseFloat(pj.u_valor_total_contrato);
  }
  g_form.setValue('u_total_projects_value',vls_pj);
}

=============================================

Show this, no formatting...

find_real_file.png

What's wrong?

1 ACCEPTED SOLUTION
2 REPLIES 2

Masarrat Siddi1
Kilo Guru

For currency fields, you need to provide currency symbol along with the value. Please refer below code snippet

 

//Get value

var rate = parseFloat(current.base_rate);

// Get currency var currencyCode = current.base_rate.getCurrencyCode();

//Perform calculation
var
totalCost = rate*current.hourly_rate;

//set the value currency.total_cost.setValue(currencyCode + ";" + totalCost);


Thanks!!