Execute JavaScript from rules: Difference between revisions

Jump to navigation Jump to search
Line 57: Line 57:
                 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.
                 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.
                 account.addAttributes();
                 account.addAttributes();


                 var fetch = new MobileCRM.FetchXml.Fetch(account);
                 var fetch = new MobileCRM.FetchXml.Fetch(account);
Line 68: Line 66:
             });
             });
         }
         }


         function getContactEntity() {
         function getContactEntity() {
Line 75: Line 71:
                 var contact = new MobileCRM.FetchXml.Entity("contact"); // NOTE: If we save to shared variable of type entity ACCOUNT, we need to create/fetch account entity.
                 var contact = new MobileCRM.FetchXml.Entity("contact"); // NOTE: If we save to shared variable of type entity ACCOUNT, we need to create/fetch account entity.
                 contact.addAttributes();
                 contact.addAttributes();


                 var fetch = new MobileCRM.FetchXml.Fetch(contact);
                 var fetch = new MobileCRM.FetchXml.Fetch(contact);
                 fetch.execute("DynamicEntities", function (res) {
                 fetch.execute("DynamicEntities", function (res) {
                     var current = res[getRandomInt(res.length)];
                     var current = res[getRandomInt(res.length)];


                     var entity = new MobileCRM.DynamicEntity(current.entityName, current.id, current.primaryName, clearInvalidProps(current.properties));
                     var entity = new MobileCRM.DynamicEntity(current.entityName, current.id, current.primaryName, clearInvalidProps(current.properties));
Line 90: Line 81:
             });
             });
         }
         }
        function modifyCurrentEntitySimple(entityForm) {
            entityForm.entity.properties.fax = getRandomInt(10);
        }


         function getLookUp() {
         function getLookUp() {
Line 103: Line 86:
                 var contact = new MobileCRM.FetchXml.Entity("contact");
                 var contact = new MobileCRM.FetchXml.Entity("contact");
                 contact.addAttributes();
                 contact.addAttributes();


                 var fetch = new MobileCRM.FetchXml.Fetch(contact);
                 var fetch = new MobileCRM.FetchXml.Fetch(contact);
Line 113: Line 94:
             });
             });
         }
         }


         function getInteger() { return getRandomInt(128); }
         function getInteger() { return getRandomInt(128); }
Line 126: Line 105:
             for (var i = 0; i < getRandomInt(); i++)
             for (var i = 0; i < getRandomInt(); i++)
                 res.push(getRandomString());
                 res.push(getRandomString());


             return res;
             return res;
Line 136: Line 113:
         }
         }




         // **** Helpers ****
         // **** Helpers ****


         function getRandomString(length) {
         function getRandomString(length) {

Navigation menu