Google Apps Script를 통해 연락처를 만들고 전화 번호를 추가 할 수 있지만 주소를 추가 할 수 없으며 "요청한 리소스를 찾을 수 없습니다."라는 오류 메시지가 표시됩니다.
참고 : fName, actualLastName, 이메일, 주소 및 phone1은 모두 문자열입니다.
// create the Contact
var newContact = ContactsApp.createContact(fName, actualLastName, email);
var newName = newContact.getFullName();
Logger.log("newName: " + newName);
Logger.log("New contact added");
// attempt to add the address - DOESN'T WORK
try {
Logger.log("Wanting to add this address: ", address);
newContact.addAddress(ContactsApp.Field.WORK_ADDRESS, address);
Logger.log("Address added");
} catch(err) {
Logger.log("Stumbled while trying to add address: " + err.message);
Browser.msgBox("Stumbled while trying to add address to contact");
}
기록 된 오류 메시지는 다음과 같습니다. "주소를 추가하는 동안 정보 실패 : 요청한 리소스를 찾을 수 없습니다."
전화 번호 추가는 정상적으로 작동합니다.
newContact.addPhone(ContactsApp.Field.MOBILE_PHONE, phone1);
그리고 연락처가 해당 그룹에 추가됩니다.
var group = ContactsApp.getContactGroup("System Group: My Contacts");
group.addContact(newContact);
한 가지 해결 방법으로 다음 수정을 제안하고 싶습니다. 이 수정에서는 연락처가 생성 될 때 연락처 ID가 검색됩니다. 그리고 addPhone
및 addAddress
연락처 ID로 검색하는 연락처 개체에 사용됩니다.
var newContact = ContactsApp.createContact(fName, actualLastName, email);
var contactId = newContact.getId();
var c = ContactsApp.getContactById(contactId);
c.addAddress(ContactsApp.Field.WORK_ADDRESS, address);
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다