0
votes

So I have a Status Dropdown on a fragment page (used to edit database entries) that I want to send an email notification when the entry changes from "Pending" to "Ready to Build".

I am using the following code:

var widgets = widget.parent.descendants;
    var to = '[email protected]';
    var subject = 'New System Order: ' + widgets.ProjectName.value;
    var msg = "A new order for [ " + widgets.ProjectName.value + " ] has been created for [ " + widgets.UsersPosition.value + " ]";
    sendMessage(to, subject, msg);

You can see that I also have it pulling the Project Name/User Position in the subject/body of the email. These are Text Boxes on that Fragment page displaying the information from the entry.

All of these works great and exactly as desired when the Dropdown and the Text Boxes are all in the same panel. However, when I separate them into separate panels (for aesthetics) the system cannot find widgets.ProjectName.value or widgets.UsersPosition.value.

I'm assuming I just need to adjust the var widgets = widget.parent.descendants; line, but I don't know to what.

Any help would be greatly appreciated. Thank you.

2

2 Answers

1
votes

So it looks like I just need to change widget.parent.descendants; to widget.root.descendants;

0
votes

I would recommend you to use Model events instead. App Maker will fire the 'onSave' event every time a record is modified.

Go to the 'Events' tab in the model editor, and add something like:

if (oldRecord.State == "Pending" && record.State == 'Ready to Build') {
  sendEmail_();
}

You can learn more about model events here.

Regards,

Julian.-