Please look into this javascript part.
Goal is to attach the newly created record towards more related objects (more then one).
The first attachment works fine, the second not.
var v_bandserienummerid = {!R262070.id};
if (v_bandserienummerid === 0)
{
rbv_api.println(v_bandserienummerid);
var v_arr = [];
v_arr['name'] = {!name#text};
v_arr["R262070"] = {!id};
v_arr["R126650862.R_supplyscope_tyre1"] = {!R126650862#id}; // supplyscope
var recordId = rbv_api.createRecord("tyre1", v_arr);
if(recordId > 0)
{
rbv_api.attach("R262070", "vehicletyre", {!id}, "tyre1", recordId);
}
if(recordId > 0)
{
rbv_api.attach("R126650862", "supplyscope", {!R126650862#id}, "tyre1", recordId);
}
}
else
{
// do nothing
// rbv_api.println(v_bandserienummerid);
}
If you move your second attachment line inside the brackets of the first one, does that solve the issue. Something like this
var v_bandserienummerid = {!R262070.id};
if (v_bandserienummerid === 0)
{
rbv_api.println(v_bandserienummerid);
var v_arr = [];
v_arr['name'] = {!name#text};
v_arr["R262070"] = {!id};
v_arr["R126650862.R_supplyscope_tyre1"] = {!R126650862#id}; // supplyscope
var recordId = rbv_api.createRecord("tyre1", v_arr);
if(recordId > 0)
{
rbv_api.attach("R262070", "vehicletyre", {!id}, "tyre1", recordId);
rbv_api.attach("R126650862", "supplyscope", {!R126650862#id}, "tyre1", recordId);
}
else
{
// do nothing
// rbv_api.println(v_bandserienummerid);
}