Can I pass JS objects to Object Script API methods?

Posted by Rollbase User on 23-Apr-2012 19:44

Hi - I see in the documentation that Object Script API methods expect JS arrays where they expect field values. The arrays are to include name/value pairs, one per field. One example is: var x = new Array(); x["amount"]=1000; x["R477842"]={!id}; x["name"]="API Created"; var newId = rbv_api.createRecord("item", x); Is it acceptable to pass a JS object instead of a JS array? For example, I would like to do this for the above: var newId = rbv_api.createRecord("item", {amount:1000,R477842:{!id},name:"API Created"});

All Replies

Posted by Admin on 23-Apr-2012 22:53

Yes, it should have the same effect.

Posted by Admin on 23-Apr-2012 22:55

Thanks, Pavel - Nathan

Posted by Admin on 23-Apr-2012 23:33

Nathan, let us know if you experience any issues passing an object versus an array.



Thanks,

Matt

Posted by Admin on 23-Apr-2012 23:57

Sure thing, Matt. I'll keep an eye out for it. So far it seems to work as I'd expect it to. I've passed Date objects, dates as milliseconds, and booleans, and they all landed in the record.

This thread is closed