0
@RestResource(urlMapping='/v/restAPIKeyGeneration/*')
global with sharing class APIforKeyGeneration{
    @HttpPost
    global static String createAccount(){
    SourceMDMRestAPI.GenerateKey();
    return 'record crea';
    }
}

public class SourceMDMRestAPI{
public static string GenerateKey(){
string keyGenerationString='';
    string keyGenerationString1='';
       Account m=new Account(Name='sarada',BillingCity='rere',BillingPostalCode='12',Phone='8008809995');
        system.debug('m.Candidate_Key__c'+m.Candidate_Key__c);
        if(m.Phone != ''){
      system.debug('if calles'+ m.Candidate_Key__c);
      m.Candidate_Key__c=m.Phone;
       system.debug('if calles'+ m.Candidate_Key__c);
      string s=m.Candidate_Key__c;
     } 
      if(m.Name != '' && m.BillingCity!= ''){
      system.debug('if calles'+ m.Candidate_Key3__c);
      keyGenerationString += KeyFormationTriggerController.toSoundex(String.valueof(m.Name));
      keyGenerationString1 += KeyFormationTriggerController.Metaphone(String.valueof(m.BillingCity));
      m.Candidate_Key3__c=keyGenerationString+keyGenerationString1;
      string r=m.Candidate_Key3__c;
            system.debug('if calles'+ m.Candidate_Key3__c);

      }


    return m.Candidate_Key__c+':'+m.Candidate_Key3__c;
}
}

Urgent requirement, please help how can i do it ? can i create a record from this SourceMDMRestAPI.GenerateKey(); without using insert m; statement

0

Yes, its just a normal method call that returns a value so:

@HttpPost
global static String createAccount(){
    String key = SourceMDMRestAPI.GenerateKey();
    // Use key in here...
    return 'record crea';
}
| improve this answer | |
  • my question is ,,can i create a record from this SourceMDMRestAPI.GenerateKey(); without using insert m; statement – Satya Sep 16 '16 at 9:30
  • @sahisfdc To create a record in the database you have to use an insert. Why don't you want to do an insert? – Keith C Sep 16 '16 at 10:00
  • if i use insert ,trigger will be fired ryt,,i dnt want to fire the trigger,using webservices post method,to create – Satya Sep 16 '16 at 11:18
  • @sahisfdc If by "create" you mean insert in the database then you are stuck. Unless it is your trigger: if it is your trigger you can set a static field while you do the insert and check that in the trigger. – Keith C Sep 16 '16 at 11:25
  • forget about the trigger,is there any way,can create create without using insert that means,using webservice as shown in above code,,please let me know,thanks in advance – Satya Sep 16 '16 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.