Join the Power Platform Masterclass #2 starting April 23

Execute JavaScript from rules: Difference between revisions

Jump to navigation Jump to search
Line 45: Line 45:
         function getAccountEntity() {
         function getAccountEntity() {
             return new Promise(function(resolve, reject) {
             return new Promise(function(resolve, reject) {
                 var contact = new MobileCRM.FetchXml.Entity("account"); // NOTE: If we save to shared variable of type entity ACCOUNT, we need to create/fetch account entity.
                 var account = new MobileCRM.FetchXml.Entity("account"); // NOTE: If we save to shared variable of type entity ACCOUNT, we need to create/fetch account entity.
                 contact.addAttributes();
                 contact.addAttributes();


Line 86: Line 86:
             var dt = new Date();
             var dt = new Date();
             return dt.toLocaleTimeString();
             return dt.toLocaleTimeString();
        }
        function modifyCurrentEntity(entityForm) {
            entityForm.entity.properties.fax = getRandomInt(10);
        }
        function clearInvalidProps(properties, invalidProps) {
            var invProps = invalidProps || [];
            var props = {};
            for (var p in properties) {
                if (p.startsWith('_') || p.startsWith("shared") || invProps.indexOf(p) > -1)
                    continue;
                var pp = properties[p];
                props[p] = pp;
            }
            return props;
         }
         }


Navigation menu