저는 자바 스크립트에 대해 매우 익숙하며 Google 스프레드 시트와 메일에서 편지 병합 기능을 사용하려고합니다. 튜토리얼 스크립트를 복사하고 몇 가지 필요한 변경을했습니다 (적어도 내가 생각할 수있는 것). 하지만 스크립트를 실행하려고하면 TypeError가 발생합니다. null에서 "length"속성을 읽을 수 없습니다. (43 행)TypeError : null에서 "length"속성을 읽을 수 없습니다.
위의 43 행은 for 루프입니다. 누군가가 스크립트를 실행할 수 있도록 수정해야 할 부분을 알려주는 데 도움을 줄 수 있습니까?
// Replaces markers in a template string with values define in a JavaScript data object.
// Arguments:
// - template: string containing markers, for instance ${"Column name"}
// - data: JavaScript object with values to that will replace markers. For instance
// data.columnName will replace marker ${"Column name"}
// Returns a string without markers. If no data is found to replace a marker, it is
// simply removed.
function fillInTemplateFromObject(template, data) {
var email = template;
// Search for all the variables to be replaced, for instance ${"Column name"}
var templateVars = template.match(/\$\{\"[^\"]+\"\}/g);
// Replace variables from the template with the actual values from the data object.
// If no value is available, replace with the empty string.
for (var i = 0; i < templateVars.length; ++i) {
// normalizeHeader ignores ${"} so we can call it directly here.
var variableData = data[normalizeHeader(templateVars[i])];
email = email.replace(templateVars[i], variableData || "");
}
return email;
}
음 ... 죄송합니다. 자바 스크립트에 대해 더 많이 알고 싶지만 그렇지 않습니다. 나는 그것을 어떻게 확인하는지 잘 모른다. – user1755506
'for' 루프를 작성하는 방법을 알고 있지만'if' 구문은 작성하지 않았습니까? 업데이트 된 답변보기 – Barmar
Google doc에서 스크립트를 가져 왔습니다. :) 내 요구 사항을 충족하기 위해 조정할 필요가 있습니다. 문제가 발생했습니다. 죄송합니다 ... – user1755506