Resco JavaScript Bridge: Difference between revisions

Jump to navigation Jump to search
Line 1,441: Line 1,441:
==== OnSave event ====
==== OnSave event ====


The final example shows how to handle the onSave event. It cancels validation and discards the error message if the value of the question is correct.
This example shows how to handle the onSave event. It cancels validation and discards the error message if the value of the question is correct.


<syntaxhighlight lang='js'>
<syntaxhighlight lang='js'>
Line 1,458: Line 1,458:
   return true;
   return true;
}, true, null); </syntaxhighlight>
}, true, null); </syntaxhighlight>
==== Repeatable groups ====
Two events handle working with repeatable groups:
* When a group is repeated
* When a group is deleted
<syntaxhighlight lang='js'>
MobileCRM.UI.QuestionnaireForm.onDeleteGroup(
  function (qForm) {
    var deletedGroupId = qForm.context.group;
    var deletedGroup = qForm.groups.find((g) => g.id === deletedGroupId);
    MobileCRM.bridge.alert("Deleted group: " + deletedGroup.label);
  },
  true,
  null
);
MobileCRM.UI.QuestionnaireForm.onRepeatGroup(
  function (qForm) {
    var newGroupId = qForm.context.newGroup;
    var sourceGroupId = qForm.context.sourceGroup;
    var newGroup = qForm.groups.find((g) => g.id === newGroupId);
    var sourceGroup = qForm.groups.find((g) => g.id === sourceGroupId);
    MobileCRM.bridge.alert(
      "Repeated group: " + newGroup.label + " from " + sourceGroup.label
    );
  },
  true,
  null
); </syntaxhighlight>


== Route plan ==
== Route plan ==

Navigation menu