Reputation: 31
I was wondering how I can change the key of an action field through scripting in Zapier. I know I need to use KEY_pre_write to change an element before I send the request but how can I call the specific action field and change the key name in something else?
The key name is currently "type" but I want to change it for instance to "type1".
Thanks in advance.
Upvotes: 1
Views: 213
Reputation: 31
Fixed it myself btw, maybe for someone who needs to know.
'use strict';
var Zap = {
CompanyAdd_pre_write: function(bundle) {
var actionfields = bundle.action_fields;
var stringify = JSON.stringify(actionfields);
var body = stringify.replace("type1", "type"); // renaming key
bundle.request.data = body;
console.log(actionfields);
return bundle.request;
}
};
Upvotes: 1
Reputation: 5262
David here, from the Zapier Platform team.
key
is set by the key of the action itself. See here:
Those would be action_pre_write
, broken_js_pre_write
, etc. Feel free to tweak these for a private app, but note that it'll break any existing zaps that use that action.
Let me know if you've got any other questions!
Upvotes: 0