Vyntex
Vyntex

Reputation: 21

Set field value

I have userevent script that I need to add a + 1 value to a field on edit.

This is what I have so far:

nlapiSubmitField('custbody1', + '1');

I am receiving an error, invalid expression. Please assist if you can.

Thanks

Upvotes: 0

Views: 1650

Answers (2)

Rusty Shackles
Rusty Shackles

Reputation: 2850

You will need to store the returned value of nlapiGetFieldValue in a variable before using nlapiSetFieldValue. Something like:

var x = nlapiGetFieldValue('field1');
nlapiSetFieldValue('field1', parseInt(x) +1);

Upvotes: 2

erictgrubaugh
erictgrubaugh

Reputation: 8902

+ '1' is not valid JavaScript syntax.

You will need to retrieve the current value from custbody1 (presumably with a lookup), parse it as a Number, add 1 to the result, then that result is what you will pass to nlapiSubmitField.

Upvotes: 2

Related Questions