Hello. I want to allow the user to edit the “extendedFields” of contacts.
Referring to this, I wrote the code, and set [suppressAuth] to [true].
However, in the case of an Admin account, editing “extendedFields” works smoothly, but it does not work with a newly registered account.
When i look at the log, it says
Uncaught (in promise) Error: Unable to handle the request. Contact the site administrator or view site monitoring logs for more information.
This error pops up.
Can someone help?
Thanks for reply. and Sure, This is backend.
export async function overwriteContactInfo ( contactId , updatedContactInfo , options ) {
// Get the contact’s last revision number
const myContact = await contacts . getContact ( contactId );
const contactIdentifiers = {
contactId : contactId ,
revision : myContact.revision
};
return await contacts . updateContact ( contactIdentifiers , updatedContactInfo , options );
}
and this is front
$w ( “#button2 ” ). onClick (() => {
$w . onReady ( async function () {
**let** UID = $w ( '#input4' ). value ;
//current member's contactId
**function** getcontact ( options ) {
**return** currentMember . getMember ( options )
. then ( member => { **return** Promise . resolve ( member.contactId );})
. **catch** ( err => console . log ( err ));
}
**const** contactId = '' + **await** getcontact ();
**const** contactInfo = {
extendedFields : {
"custom.uid" : UID
}
};
**const** options = {
allowDuplicates : **false** ,
suppressAuth : **true**
};
overwriteContactInfo ( contactId , contactInfo , options );
})
});
});
is there anything wrong this code?
J.D
November 29, 2022, 10:01am
4
Front end:
The $w(“#button2 ”).onClick(() must be inside the $w.onReady block and not vice versa.
Backend:
Unlike the updateContact method, the getContacat options shouldn’t have the allowDuplicates key at all.
A few additional minor changes (that probably are not relevant to the problem):
I’d get rid of the final “await” in the backend function return (it’s not needed. however it won’t solve the problem).
I’d move the options to the backend code instead of passing it from the front end.
Thank you Problem solved. the problem is
Backend:
Unlike the updateContact method, the getContacat options shouldn’t have the allowDuplicates key at all.
I put the option
const options = {
suppressAuth : true
};
for the getContact, and it works!
Thank you again. and Have a nice day