Hi there,
I have a function (shown below) that creates 1 object in object type reportLevelQAT and then multiple objects in object type answersQAT. When testing the function in the functions preview in code repository, it successfully does as expected but when I load it as an action into my workshop app, it does not work (only creates the single object in reportLevelQAT).
Do you have any recommendations as to why this is and how to resolve it?
Thank you!
@Edits(ReportLevelQAT, AnswersQAT)
@OntologyEditFunction()
public async CreateQuestionObjects(auditType: string, roleSelected: string, areaName: string, currentUserId: string): Promise<void> {
// Create report level object
const newReport = Objects.create().reportLevelQAT(Uuid.random());
newReport.DepartmentName = areaName;
newReport.roleType = roleSelected;
newReport.inspectionName = auditType;
newReport.inspectorID = currentUserId;
newReport.submitTime = Timestamp.now();
// Identify all questions to be answered in the report
const requiredQuestions = await Objects.search()
.questionSetQAT()
.filter(i => i.inspectionName.exactMatch(auditType))
.allAsync();
// Create question level objects to be modified during inspection completion
for (const requiredQuestion of requiredQuestions) {
const QuestionAnswer = Objects.create().answersQAT(Uuid.random());
QuestionAnswer.questionId = requiredQuestion.questionId;
QuestionAnswer.questionText = requiredQuestion.questionText;
QuestionAnswer.reportId = newReport.reportId;
QuestionAnswer.submitTime = Timestamp.now();
}
}