Cant change owner, created by and modified by fields on costume module

Cant change owner, created by and modified by fields on costume module

Hello!


Recently we created a costume module to track Service orders after a deal is won, everything is working fine except that no matters who created (and closes) the deal, the service order module always created a service order using the account of the super admin.

 

Here’s the code we are using in a costume function to create the service order and change the owner of the fields we want.

 

The funny thing is that we even created another single line field to paste the values of the owner and it works 50%, it does pastes a different owner than the superadmin, but it doesn’t pastes is right (check the screenshots).

 

Hope you can help me out!

 

void Untitled_Function33 (int OrdVenID )

OVDetails = zoho.crm.getRecordById("SalesOrders",input.OrdVenID);

mp=map();

mp.put("CustomModule7 Name",ifnull(OVDetails.get("Subject"),""));

mp.put("Orden de Venta",ifnull(OVDetails.get("Subject"),""));

mp.put("No. Orden de Venta",ifnull(OVDetails.get("Orden de Venta"),""));

mp.put("Cliente",ifnull(OVDetails.get(("Account Name")),""));

mp.put("Contacto",ifnull(OVDetails.get("Contact Name"),""));

mp.put("Orden de Servicio Owner",zoho.loginuserid);

// next 2lines is supposed to record the owner, it doesnt works

mp.put("Created by",zoho.loginuserid);

mp.put("Modified by",zoho.loginuserid);

creat = zoho.crm.create("CustomModule7",mp);

info mp;

info creat;

recID=creat.get("Id");

info "New Record ID: " + recID;

userID=zoho.loginuser;

info "Login User ID: " + userID;

// next line is a double check, i can get  the real owner out, but i cant place it on the fields i want, and when i paste it on other field, it pastes it wrong

update = zoho.crm.updateRecord("CustomModule7",recID.toString(),{ "Propietario Orden de Servicio" : userID });

info "Record Updated: " + update;

recGET = zoho.crm.getRecordById("CustomModule7",recID.toLong());

info "New Record: " + recGET;