Skip to content

Action Examples

David Yack edited this page Jan 10, 2017 · 8 revisions

Node JS example of qualifying a lead

api.Create("leads",
   {subject:'test lead', firstname:'John', lastname:'Smith'}).then(function(leadID)
{
    console.log('Lead Id is ' + leadID);

    var data = {
            "CreateAccount": true,
            "CreateContact": true,
            "CreateOpportunity": true,
            "Status":3
        };

    api.ExecuteAction('Microsoft.Dynamics.CRM.QualifyLead', 
                data, 'leads' , leadID).then(function(result){
        console.log('lead qualified ' + result);
    },function(error){console.log(error)})
},function(error){console.log(error)}

);

Node JS example of adding a Web Resource to a Solution

var actionParams = { 
    'ComponentId':'9D084652-9BD3-E611-8106-C4346BB59828' ,
    'ComponentType':61,
    'SolutionUniqueName':'test',  
    'AddRequiredComponents':false,
    'IncludedComponentSettingsValues':null
};
api.ExecuteAction('AddSolutionComponent',actionParams).then(function(results)
        {console.log(results)},function(error){console.log(error)});

Node JS example of execute workflow

var actionParams = { 
    'EntityId':'1BF8108F-FF95-E421-80DA-00155D28E90E'    
};
crmAPI.ExecuteAction('Microsoft.Dynamics.CRM.ExecuteWorkflow',
        actionParams,"workflows","3F841295-5EBE-4230-9EAB-B562E726B188").then(
                 function(results){console.log(results); },
               function(error){console.log(error)});