Back to top

Areas


Customers

1.Create new customers or updates existing customer info records.

  • If customer exists with same account ID then existing customer info record will get updated, otherwise new customer info record will be created.

Method signature

    Map<String, Object>  addCustomers(List<CustomerData> customers, Integer version)

CustomerData Object

     {
         String account;
         Double mrr;
         Double asv;
         Double otr;
         Integer users;
         Date orgContractDate;
         Date nextRenewalDate;
         String status;
         String stage;
         SObject obj;
    }

Example 1:

    JBCXM.CEHandler.CustomerData newCustomer = new JBCXM.CEHandler.CustomerData();
    newCustomer.Account = act.id;
    newCustomer.Stage = 'New Business';
    newCustomer.Status = 'Active';
    List<JBCXM.CEHandler.CustomerData> customers = new List<JBCXM.CEHandler.CustomerData>();
    customers.add(newCustomer);        
    Map<String,Object> response = JBCXM.CEHander.addCustomers(customers,1);

Example 2:

    JBCXM.CEHandler.CustomerData newCustomer = new JBCXM.CEHandler.CustomerData();
    newCustomer.Account = act.id;
    newCustomer.Stage = 'New Business';
    newCustomer.Status = 'Active';
    newCustomer.Obj = new JBCXM__CustomerInfo__c(jbcxm__nps__c = 3);
    List<JBCXM.CEHandler.CustomerData> customers = new List<JBCXM.CEHandler.CustomerData>();
    customers.add(newCustomer);        
    Map<String,Object> response = JBCXM.CEHander.addCustomers(customers,1);

Response Map

// success case
{"nextBatchSize":1000,"errLog":[],"status":"SUCCESS","failCount":0,"passCount":1}
// failure case
{"nextBatchSize":1000,"errLog":[{"type":"Custom","jbcxm__account__c":null,"errorLog":"Invalid Account"}],"status":"FAILED","failCount":1,"passCount":0}

Scorecards

1.Set individual measure scores for customers

Method signature

    Map<String, Object> setMeasureScores(List<ScorecardData> measures, Integer version)

ScorecardData Object

     {
         String account;
         String metric;
         Double scorevalue;
         Double prevscorevalue;
         Boolean resetscore;
         String comment;
         String goals;
    }
  • You should use scorevalue to set the score for a metric.

  • If record already exits for given measure and account ID then existing record will be updated.

  • If customer roll-up summary is enabled then customer level scores are re-populated based on latest scores.

Example:

    JBCXM.CEHandler.ScorecardData score = new JBCXM.CEHandler.ScorecardData();
    score.Account = act.id;
    score.Metric = 'NPS Score';
    score.scorevalue = 20;
    List<JBCXM.CEHandler.ScorecardData> scores = new List<JBCXM.CEHandler.ScorecardData>();
    scores.add(score);     
    Map<String,Object> response = JBCXM.CEHander.setMeasureScores(scores,1);

2.Set Customer level scores

Method signature

    Map<String, Object> setCustomerScores(List<ScorecardData> measures, Integer version)

Example:

    JBCXM.CEHandler.ScorecardData score = new JBCXM.CEHandler.ScorecardData();
    score.Account = act.id;
    score.scorevalue = 20;
    score.goals = 'foo';
    score.comment = 'foo';
    List<JBCXM.CEHandler.ScorecardData> scores = new List<JBCXM.CEHandler.ScorecardData>();
    scores.add(score);     
    Map<String,Object> response = JBCXM.CEHander.setCustomerScores(scores,1);

Note: You should use scorevalue to set the score for customer overall health.

Response Map

// success case
{"nextBatchSize":1000,"errLog":[],"status":"SUCCESS","failCount":0,"passCount":1}
// failure case
{"nextBatchSize":1000,"errLog":[{"type":"Custom","jbcxm__account__c":null,"errorLog":"Invalid Account or Score"}], "status":"FAILED","failCount":1,"passCount":0}

Usage Data

1.Adding/Updating Usage Data

Load usage data by instance, account and user level.

Method signature

    Map<String, Object> addUsageData(DataWrapper dataWrapObj, Integer version)

DataWrapper Object

     {
         List<CustomerData> customers;
         List<CTAData> ctas;
         List<UsageData> usage;
         List<ScorecardData> scores;
         List<NPSResponse> npsResponses;
         List<CustomerFeature> customerFeatures;
         List<MilestoneData> milestones;
         Boolean honorOrgTimeZone;
         String usageLevel;
         SendSurveyData distributionData;
    }

UsageData Object

     {
         String account;
         String usageLevel;
         String instanceId;
         String instanceName;
         String user;
         Date usageDate;
         SObject obj;
    }

Note:

  • Required fields based on the Usage level.
    • ACCOUNTLEVEL:account and date(If multiple records are sent with same Account ID and time period then latest record will be considered for updation or creation.)
    • INSTANCELEVEL:account, date and instanceId(If multiple records are sent with same Account ID,Instance ID and time period then latest record will be considered for updation or creation.)
    • USERLEVEL: account, date and user(If multiple records are sent with same Account ID,User ID and time period then latest record will be considered for updation or creation.)

Example 1:

        JBCXM.CEHandler.UsageData usage = new JBCXM.CEHandler.UsageData();
        List<CEHandler.UsageData> usageData = new List<CEHandler.UsageData>();
        usage.account = act.id;
        usage.usageLevel = 'INSTANCELEVEL';
        usage.instanceId = '1';
        usage.instanceName = '1';
        usage.usageDate =  Date.today();
        usageData.add(usage);
        JBCXM.CEHandler.DataWrapper data = new JBCXM.CEHandler.DataWrapper();
        data.usage = usageData;
        data.usageLevel = 'INSTANCELEVEL';
        Map<String,Object> response = JBCXM.CEHander.addUsageData(data,1);

Example 2:

        JBCXM.CEHandler.UsageData usage = new JBCXM.CEHandler.UsageData();
        List<CEHandler.UsageData> usageData = new List<CEHandler.UsageData>();
        usage.account = act.id;
        usage.usageLevel = 'USERLEVEL';
        usage.user = 'User1';
        usage.usageDate =  Date.today();
        usageData.add(usage);
        JBCXM.CEHandler.DataWrapper data = new JBCXM.CEHandler.DataWrapper();
        data.usage = usageData;
        data.usageLevel = 'USERLEVEL';
        Map<String,Object> response = JBCXM.CEHander.addUsageData(data,1);

Example 3:

        JBCXM.CEHandler.UsageData usage = new JBCXM.CEHandler.UsageData();
        List<CEHandler.UsageData> usageData = new List<CEHandler.UsageData>();
        usage.account = act.id;
        usage.usageLevel = 'ACCOUNTLEVEL';
        usage.usageDate =  Date.today();
        usageData.add(usage);
        JBCXM.CEHandler.DataWrapper data = new JBCXM.CEHandler.DataWrapper();
        data.usage = usageData;
        data.usageLevel = 'ACCOUNTLEVEL';
        Map<String,Object> response = JBCXM.CEHander.addUsageData(data,1);

Response Map

// success case
{"nextBatchSize":200,"errLog":[],"status":"SUCCESS","failCount":0,"passCount":2}
// partial success
{"nextBatchSize":200,"errLog":[{"type":"Custom","jbcxm__account__c":"001i000001DPhy","jbcxm__date__c":1404777600000,"errorLog":"Invalid Account"}],"status":"PARTIAL SUCCESS","failCount":1,"passCount":1}
// failure case
{"nextBatchSize":200,"errLog":[{"type":"Custom","jbcxm__account__c":"001i000001DPhy","jbcxm__date__c":1404777600000,"errorLog":"Invalid Account"},{"type":"Custom","jbcxm__account__c":"te","jbcxm__date__c":1404777600000,"errorLog":"Invalid Account"}],"status":"FAILED","failCount":2,"passCount":0}

CTA

1.Adding/Updating CTAs

Create or update CTAs

Method signature

    Map<String, Object> addCTA(DataWrapper dataWrapObj, Integer version)

DataWrapper Object

     {
         List<CustomerData> customers;
         List<CTAData> ctas;
         List<UsageData> usage;
         List<ScorecardData> scores;
         List<NPSResponse> npsResponses;
         List<CustomerFeature> customerFeatures;
         List<MilestoneData> milestones;
         Boolean honorOrgTimeZone;
         String usageLevel;
         SendSurveyData distributionData;
    }

CTAData Object

     {
         String account;
         String name;
         String type;
         String reason;
         String priority;
         String stage;
         String assignee;
         String playbook;
         String comment;
         Integer numOfDays;
         String source;
         Date createdDate;
         Date dueDate;
         String postFrequency;
         SObject obj;
    }

Note:

  • Required fields: account, name ,reason and priority.

  • if playbook is provided in the request then it will associate the tasks of playbook to the CTA.

  • If createdDate is not provided then it will be defaulted to date.today().

  • If dueDate is not provided then it will be defaulted to createdDate + 5(excluding weekends).

  • If assignee is not provided then it will be defaulted to current session user ID.

Example 1:

        List<JBCXM.CEHandler.CTAData> ctaData = new List<JBCXM.CEHandler.CTAData>();
        JBCXM.CEHandler.CTAData cta = new JBCXM.CEHandler.CTAData();
        cta.assignee = UserInfo.getUserId();
        cta.account = act.Id;
        cta.dueDate = Date.today();
        cta.stage = 'Open';
        cta.type = 'Risk';
        cta.reason = 'Product Adoption';
        cta.Name = 'Low Usage';        
        ctaData.add(cta);
        JBCXM.CEHandler.DataWrapper data = new JBCXM.CEHandler.DataWrapper();
        data.ctas = ctaData;
        Map<String,Object> response = JBCXM.CEHander.addUsageData(data,1);

Example 2:

        List<JBCXM.CEHandler.CTAData> ctaData = new List<JBCXM.CEHandler.CTAData>();
        JBCXM.CEHandler.CTAData cta = new JBCXM.CEHandler.CTAData();
        cta.assignee = UserInfo.getUserId();
        cta.account = act.Id;
        cta.dueDate = Date.today();
        cta.stage = 'Open';
        cta.type = 'Risk';
        cta.reason = 'Survey Response';
        cta.Name = 'Low NPS Score';
        cta.Obj = new JBCXM__CTA__c(JBCXM__TaskCount__c = 3); // to set any custom field values
        ctaData.add(cta);
        JBCXM.CEHandler.DataWrapper data = new JBCXM.CEHandler.DataWrapper();
        data.ctas = ctaData;
        Map<String,Object> response = JBCXM.CEHander.addUsageData(data,1);

Response Map

// success case
{"nextBatchSize":200,"errLog":[{"type":"Custom","jbcxm__account__c":"001i00000","jbcxm__type__c":a0Qi0000003outSEAQ,"errorLog":"Invalid Account"}],"status":"PARTIAL SUCCESS","failCount":1,"passCount":1}
// failure case
{"nextBatchSize":200,"errLog":[{"type":"Custom","jbcxm__account__c":"001i00000","jbcxm__type__c":a0Qi0000003outSEAQ,"errorLog":"Invalid Account"},{{"type":"Custom","jbcxm__account__c":"001i00000","jbcxm__type__c":a0Qi0000003outSEAQ,"errorLog":"Invalid Account"}],"status":"FAILED","failCount":2,"passCount":0}

Survey

1.Adding NPS Response

Method signature

    Map<String, Object> addNPSResponses(DataWrapper data)

DataWrapper Object

     {
         List<CustomerData> customers;
         List<CTAData> ctas;
         List<UsageData> usage;
         List<ScorecardData> scores;
         List<NPSResponse> npsResponses;
         List<CustomerFeature> customerFeatures;
         List<MilestoneData> milestones;
         Boolean honorOrgTimeZone;
         String usageLevel;
         SendSurveyData distributionData;
    }

NPSResponse Object

     {
        String account;
        String userrole;
        String username;
        String useremail;
        String surveycode;
        String npscomment;
        String surveyid;
        Integer npsscore;
        Datetime respondeddate;
    }

Note:

  • Required fields account, surveycode or surveyid, useremail,npsscore and respondeddate

  • If surveycode is provided then it will check if there exists NPS survey master matching with this survey code and associate the record with that survey, otherwise it will create a new NPS master and associate the record with new one.

Example:

        List<JBCXM.CEHandler.NPSResponse> dataSet = new List<JBCXM.CEHandler.NPSResponse>();
        JBCXM.CEHandler.NPSResponse rsp = new JBCXM.CEHandler.NPSResponse();        
        rsp.account = act.Id;
        rsp.userrole= 'CSM';
        rsp.username= 'Test user1';
        rsp.useremail= 'user1@test.com';
        rsp.surveycode= 'NPS Survey1';
        rsp.npsscore= 5;
        rsp.respondeddate= datetime.newInstance(2014, 6, 10, 10, 1, 1);
        rsp.npscomment= 'comment goes here...';
        dataSet.add(rsp);
        JBCXM.CEHandler.DataWrapper data = new JBCXM.CEHandler.DataWrapper();
        data.npsResponses = dataSet;
        Map<String,Object> response = JBCXM.CEHander.addNPSResponses(data,1);

Response Map

// success case
{"nextBatchSize":100,"errLog":[],"status":"SUCCESS","failCount":0,"passCount":4}
// partial success case
{"nextBatchSize":100,"errLog":[{"type":"Custom","userrole":"PM","account":"","respondeddate":1397595661000,"useremail":"john@acme.com","errorLog":"Invalid Account or Survey Master details or NPS score","npscomment":"<script>alert(lkjadlfk jalkfj&,:;./?).asdlkflk","npsscore":5,"surveycode":"testsurey1234","username":"bad"}],"status":"PARTIAL SUCCESS","failCount":1,"passCount":3}

2.Sending Survey Emails

To distribute survey emails once the participants are added to the survey.

Method signature

    Map<String, Object> sendSurvey(SendSurveyData details, Integer version)

SendSurveyData Object

     {
         String surveyCode;
         Boolean resend;
         String fromAddress;
         String emailService;
         String templateId;
         List<SurveyParticipant__c> participants;
    }

Note : Survey should be in Publish status

Example:

        JBCXM.CEHandler.SendSurveyData distrData = new JBCXM.CEHandler.SendSurveyData();
        distrData.surveycode = sObj.Code__c;
        distrData.resend = false;
        distrData.emailService = 'SALESFORCE';
        distrData.participants = new List<SurveyParticipant__c> {participant1};
        Map<String,Object> response = JBCXM.CEHander.sendSurvey(distrData,1);

Response Map

// success case
{"status":"SUCCESS","msg": "Appropriate message"}
// failure case
{"status":"FAILURE","msg": "Failure reason"}

Milestones

1.Adding/Updating Milestones

Method signature

    Map<String, Object> addMilestone(DataWrapper dataWrapObj, Integer version)

MilestoneData Object

     {
         String account;
         Datetime milestoneDate;
         String comment;
         String milestone;
         SObject obj;
    }

Note:

  • If record already exits for given milestone and account ID then existing record will be updated.

Example:

        List<JBCXM.CEHandler.MilestoneData> msl = new List<JBCXM.CEHandler.MilestoneData>();
        JBCXM.CEHandler.MilestoneData md1 = new JBCXM.CEHandler.MilestoneData();
        md1.account = act.Id;
        md1.milestoneDate = datetime.now().addDays(-10);
        md1.comment = 'Contact Signed';
        md1.milestone = 'Contract Sign';        
        msl.add(md1);
        JBCXM.CEHandler.DataWrapper data = new JBCMX.CEHandler.DataWrapper();
        data.milestones = msl;
        Map<String,Object> response = JBCXM.CEHander.addMilestone(data,1);

Response Map

    // success case
            {
        "nextBatchSize": 1000,
        "errLog": [],
        "status": "SUCCESS",
        "failCount": 0,
        "passCount": 1
    }
    // failure case
    {
        "nextBatchSize": 1000,
        "errLog": [{
            "type": "Custom",
            "jbcxm__account__c": "001i000001DPhyhAAD",
            "jbcxm__milestone__c": null,
            "jbcxm__date__c": 1404777600000,
            "errorLog": "Milestone field is null or missing"
        }, {
            "type": "Custom",
            "jbcxm__account__c": "001i000001DPhyhAAD",
            "jbcxm__milestone__c": null,
            "jbcxm__date__c": 1404777600000,
            "errorLog": "Invalid Account"
        }],
        "status": "FAILED",
        "failCount": 2,
        "passCount": 0
    }

Features

1.Add or update features by account

Method signature

    Map<String, Object> addCustomerFeatures(DataWrapper dataWrapObj, Integer version)

CustomerFeature Object

     {
        String account;
        String feature ;
        String comment;
        Boolean licenced;
        Boolean enabled;
        SObject obj;
    }

Note:

  • If record already exits for given feature and account ID then existing record will be updated.

Example:

        List<JBCXM.CEHandler.CustomerFeature> cfl = new List<JBCXM.CEHandler.CustomerFeature>();
        JBCXM.CEHandler.CustomerFeature cf1 = new JBCXM.CEHandler.CustomerFeature();
        cf1.account = act.Id;
        cf1.feature = 'F1';
        cf1.comment = 'test comment';
        cf1.enabled = true;
        cf1.licenced = true;
        cfl.add(cf1);
        JBCXM.CEHandler.DataWrapper data = new JBCXM.CEHandler.DataWrapper();
        data.customerFeatures = msl;
        Map<String,Object> response = JBCXM.CEHander.addMilestone(data,1);

Response Map

// success case
{ "nextBatchSize": 1000, "errLog": [], "status": 
"SUCCESS", "failCount": 0, "passCount": 1 }

Generated by aglio on 17 Feb 2015