• bhagya manshani
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies

I am calling web service( Generated from WSDL) from trigger . 

// Here is my trigger

trigger reminder on Lead (after insert) {
  
  ///Lead[]lead = Trigger.new; 
  //reminderTask.setRemainder(lead);
  //reminderTask.SetConverted_LeadFalse();
  //myclass.test();
  //testforweb ob=new testforweb();
  //String token= ob.testweb();
    call_webtest.myMethod(); 

 

 

 

 

trigger reminder on Lead (after insert) {  

    String token = call_webtest.myMethod(); 

}

// Here is my class

   global class call_webtest {


   public global static String token;

     

    @future(callout=true) public static void myMethod()

    {

           wwwWso2OrgPhp.QMetryWSSOAPPort_Http obj = new wwwWso2OrgPhp.QMetryWSSOAPPort_Http();

            token = obj.login('amardeep','amardeep1@#4');   // get the token from web service( No Problem In That)

         Question:  I want to return that Token in my Trigger But Future method must be void and no Return Statement

     }

    

}

 

How Can I resolve that Problem Please Help .  I need that Token In My trigger

// Here is my Apex class........

 

   global  class schedule_class  implements Schedulable  {
   
        //public static String CRON_EXP = '0 0 20 * * ? 2010';     //'0 0 0 3 9 ? 2022'
     global void execute(SchedulableContext ctx)
     {
     
        System.debug('**************************************');
      }
 }

// End of Class

 

// Here is my test method to call that class

 

  @isTest
private class mergeNumbers {

    static testMethod void myUnitTest() {
        // TO DO: implement unit test
        schedule_class m = new schedule_class();
        String sch = '20 30 8 10 2 ?';
        system.schedule('Merge Job', sch, m);
    }
}

// My Question  is : When i test this method on that Execute () is not Covering Or we can say that not able to get execute()

   Please Help...............Dear Thanks a lot in Advance plz    

   Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

    String[] toAddresses = new String[] {'bhagchand.manshani@infostretch.com'};
      mail.setToAddresses(toAddresses);
      mail.setSubject('Qmetry Instance Already Exist......');
        mail.setUseSignature(false);
           String Msg='Here are the Following Details';                                                                                  
             mail.setHtmlBody(Msg);
              System.debug('Final Message '+msg);                 
              Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

 

 

// Email Part End Here

  // Trigger.old[0].addError('metry Instance Already Exist flag value.');      // Not Working

   //lead.Company.addError('Qmetry Instance Already Exist flag value ....... ');                            // Not Working

  // Trigger.oldMap.get(lead.Company).addError('metry Instance Already Exist flag value.'); // Not Working

 

Please Help Thanks in Adv.

 

// Here is my Apex class........

 

   global  class schedule_class  implements Schedulable  {
   
        //public static String CRON_EXP = '0 0 20 * * ? 2010';     //'0 0 0 3 9 ? 2022'
     global void execute(SchedulableContext ctx)
     {
     
        System.debug('**************************************');
      }
 }

// End of Class

 

// Here is my test method to call that class

 

  @isTest
private class mergeNumbers {

    static testMethod void myUnitTest() {
        // TO DO: implement unit test
        schedule_class m = new schedule_class();
        String sch = '20 30 8 10 2 ?';
        system.schedule('Merge Job', sch, m);
    }
}

// My Question  is : When i test this method on that Execute () is not Covering Or we can say that not able to get execute()

   Please Help...............Dear Thanks a lot in Advance plz    

I'm having trouble sending out an email message if I use an adderror. I've read in the apex docs that its not processing since the adderror does not allow the tranaction to commit. Knowing this is the case, what alternatives do I have?

 

Ultimately, I want to prevent a user from deleting a contact when there are licenses and I also want to be notified that the action has taken place. I think I might have to get creative for this. Here is the trigger I have so far:

 

 

trigger PreventDelete on Contact (before delete) {
for (License__c l : [select contact__c from license__c
where contact__c in :Trigger.oldMap.keySet()]) {

//Setup email and send
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'email@acme.com'};
mail.setToAddresses(toAddresses);
mail.setReplyTo('emaiL@acme.com');
mail.setSenderDisplayName('Salesforce Support');
mail.setSubject('Contact Deletion Attempted');
mail.setBccSender(false);
mail.setUseSignature(false);
mail.setPlainTextBody('A contact delete was attempted.');
mail.setHtmlBody('Review contact for deletion<p>'+
' View license<a href=https://na5.salesforce.com/l.id>click here</a>');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

Trigger.oldMap.get(l.contact__c).addError('Contact has licenses attached. Support has been notified.');
}
}

 

 

 

email@acme