• revathy
  • NEWBIE
  • 34 Points
  • Member since 2013
  • Sr.software engg
  • Renault nissan

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 1
    Likes Given
  • 15
    Questions
  • 5
    Replies
HttpRequest req2 = new HttpRequest();
req2.setEndpoint('https://api.twitter.com/1.1/search/tweets.json?q=Redigo');
req2.setMethod('GET');
String access_token = '209178935-GmPOB96pKNYOV090I8ke4DM5M8gzxr9AzezG6eZH';
String authorizationHeader = 'Bearer ' + access_token;
//req2.setHeader('Bearer ' + access_token);
req2.setHeader('Authorization', authorizationHeader);
Http http = new Http();
HTTPResponse res = http.send(req2);
String sBody = res.getBody();
system.debug('@@'+ sBody);

please me some urgent
i have javascipt button "MassEmail" in campaign detail page,when we click the button send the email to all related campign members.In this purpose i have created one Html email template for campaign objects.But in email template i am not able display"detail page link".
========
Javascript code
==========
{!REQUIRESCRIPT('/soap/ajax/26.0/connection.js')} 
{!REQUIRESCRIPT('/js/functions.js')} 
{!REQUIRESCRIPT('/resource/Rfleet_JqyeryUI_STR/jquery1/js/jquery-1.8.3.js')} 
{!REQUIRESCRIPT('/resource/Rfleet_JqyeryUI_STR/jquery1/js/jquery-ui-1.9.2.custom.min.js')} 

var Contactids=[]; 
var recordname=[]; 
var emailids=[]; 
var contactname=[]; 

var CamMember=sforce.connection.query("SELECT CampaignId,ContactId FROM CampaignMember where CampaignId='{!Campaign.Id}'"); 
var records = CamMember.getArray("records"); 

for (var i=0; i<records.length; i++) { 
recordname = records[i]; 
Contactids.push(recordname.ContactId); 



var con=sforce.connection.query('SELECT Id,Email '+'FROM Contact where id in (\'' + Contactids.join('\',\'') + '\')'); 

var contactemail = con.getArray("records"); 

for (var i=0; i<contactemail.length; i++) { 
contactname = contactemail[i]; 
emailids.push(contactname.Id); 



for (var i=0; i<emailids.length; i++) { 

var message = new sforce.SingleEmailMessage(); 
message.replyTo = "rapsac@gmail.com"; 
message.targetObjectId=emailids[i]; 
message.templateId ="00X4E000000EMXt"; 
var result = sforce.connection.sendEmail([message]); 

if(result[0].success == 'true') { 
alert("I sent the email as you requested, master."); 
} else { 
alert("I had a booboo."); 
}
==========
email template
========
User-added image

Advanced thanks for helping:)
I have samll clarifications how to use  Map<string,list<Date>> like that?
My scenario is :i have two fields Dealer number,Date from soql query i got the values below that.
Date ------     Dealer number
10/02/2017    10100
15/01/2017    10100
02/02/2017    10100

01/02/2017    10101
05/02/2017    10101
10/01/2017    10102
31/01/2017    10102

I want output based on Dealer number.see one Dealer having different dates.this Dealer 10100 having 3 different dates,Month of JAN(count is 1) and Month Feb(count is 2).count is calucuted based on same month based. 
output should be:

Dealer-----FebMonth(Count)-----JanMonth(Count)
10100 ----------------2-----------1

please guide me how to achive this scenario?

Advanced thanks
i have provided Test class & Apex class and code coverage test screen.
======apex class=========
 //period1 LowerDate validation 
public PageReference Period1LowerDateValidation(){

       if(acc.Rfleet_LowerDate_Period1__c!=Null && acc.Rfleet_LowerMonth_Period1__c != Null && acc.Rfleet_UpperMonth_Period1__c!=null && acc.Rfleet_UpperDate_Period1__c !=null ){
         boolsave=false;
          if((Integer.valueof(acc.Rfleet_LowerDate_Period1__c)> Integer.valueof(acc.Rfleet_UpperDate_Period1__c)) && (acc.Rfleet_LowerMonth_Period1__c==acc.Rfleet_UpperMonth_Period1__c)){
                boolsave=true;             
                ApexPages.Message msg = new Apexpages.Message(ApexPages.Severity.Warning,'Please select the past Date of lowerdate in Period1!!');
                ApexPages.addmessage(msg);
                 
          }else if((Integer.valueof(acc.Rfleet_LowerDate_Period1__c)== Integer.valueof(acc.Rfleet_UpperDate_Period1__c)) && (acc.Rfleet_LowerMonth_Period1__c==acc.Rfleet_UpperMonth_Period1__c)){
                boolsave=true;
                ApexPages.Message msg = new Apexpages.Message(ApexPages.Severity.Warning,'Should not same lowerdate/UpperDate in Period1!!');
                ApexPages.addmessage(msg);
                 
          }else if((acc.Rfleet_UpperMonth_Period1__c=='M') &&(acc.Rfleet_LowerMonth_Period1__c=='M + 1'||acc.Rfleet_LowerMonth_Period1__c=='M + 2'|| acc.Rfleet_LowerMonth_Period1__c=='M + 3')){
          // }else if((acc.Rfleet_UpperMonth_Period1__c=='M') && (acc.Rfleet_LowerMonth_Period1__c.contains('M + 1,M + 2,M + 3'))){
                boolsave=true;
                ApexPages.Message msg = new Apexpages.Message(ApexPages.Severity.Warning,'Please select the past month LowerDate in Period1!!');
                ApexPages.addmessage(msg);
                 
          }else if((acc.Rfleet_UpperMonth_Period1__c=='M + 1') &&(acc.Rfleet_LowerMonth_Period1__c=='M + 2'|| acc.Rfleet_LowerMonth_Period1__c=='M + 3')){
                boolsave=true;
                ApexPages.Message msg = new Apexpages.Message(ApexPages.Severity.Warning,'Please select the past month LowerDate in Period1!!');
                ApexPages.addmessage(msg);
                 
          }else if(acc.Rfleet_UpperMonth_Period1__c=='M + 2' && acc.Rfleet_LowerMonth_Period1__c=='M + 3'){
                boolsave=true;
                ApexPages.Message msg = new Apexpages.Message(ApexPages.Severity.Warning,'Please select the past month LowerDate in Period1!!');
                ApexPages.addmessage(msg);
                 
          }else if((acc.Rfleet_UpperMonth_Period1__c=='M - 1') &&(acc.Rfleet_LowerMonth_Period1__c=='M'|| acc.Rfleet_LowerMonth_Period1__c=='M + 1'|| acc.Rfleet_LowerMonth_Period1__c=='M + 2'|| acc.Rfleet_LowerMonth_Period1__c=='M + 3')){
                boolsave=true;
                ApexPages.Message msg = new Apexpages.Message(ApexPages.Severity.Warning,'Please select the past month LowerDate in Period1!!');
                ApexPages.addmessage(msg);
                       
          }else if((acc.Rfleet_UpperMonth_Period1__c=='M - 2') &&(acc.Rfleet_LowerMonth_Period1__c=='M - 1'|| acc.Rfleet_LowerMonth_Period1__c=='M'|| acc.Rfleet_LowerMonth_Period1__c=='M + 1'|| acc.Rfleet_LowerMonth_Period1__c=='M + 2'|| acc.Rfleet_LowerMonth_Period1__c=='M + 3')){
               boolsave=true;
                ApexPages.Message msg = new Apexpages.Message(ApexPages.Severity.Warning,'Please select the past month LowerDate in Period1!!');
                ApexPages.addmessage(msg);
                      
          }else if((acc.Rfleet_UpperMonth_Period1__c=='M - 3') &&(acc.Rfleet_LowerMonth_Period1__c=='M - 1'|| acc.Rfleet_LowerMonth_Period1__c=='M - 2'|| acc.Rfleet_LowerMonth_Period1__c=='M'|| acc.Rfleet_LowerMonth_Period1__c=='M + 1'|| acc.Rfleet_LowerMonth_Period1__c=='M + 2'|| acc.Rfleet_LowerMonth_Period1__c=='M + 3')){
               boolsave=true;
                ApexPages.Message msg = new Apexpages.Message(ApexPages.Severity.Warning,'Please select the past month LowerDate in Period1!!');
                ApexPages.addmessage(msg);
                       
          }
          
    }
   return null;
}
=====test class========
@isTest(seealldata=true)
private class Rfleet_PaymentConditions_Test{
   static testmethod void testpayment(){
        account acc = new account(name='jira',montant__c=0.5);
        insert acc;
        acc.name='raji';
        acc.Rfleet_LowerDate_Period1__c='15';
        acc.Rfleet_UpperDate_Period1__c='10';
        update acc;
       // Test.startTest();
        PageReference tpageRef = Page.RFLEET_PaymetCondition;
        Test.setCurrentPage(tpageRef);
        ApexPages.currentPage().getParameters().put('Id', acc.Id);
        System.assertEquals( acc.id,ApexPages.currentPage().getParameters().get('Id'));
        
        Rfleet_PaymentConditions c = new Rfleet_PaymentConditions(new ApexPages.StandardController(acc));
        c.getAccount();
        c.save(); 
        c.back();
        c.Submit();
        c.ResetPayment();
        c.bool=true; 
        c.ResetDepreciationPayment();
         System.assertEquals(true, c.bool);  
        c.Period1LowerDateValidation();
        c.Period1UpperDateValidation();       
       // Test.stopTest();
        
       
    }
 }

=====Screen shot for code coverage======
User-added image
 
But last two days getting error,SAP Pi system not able to send data to SFDC?

SFDC END point URL:
https://gelighting.my.salesforce.com/services/Soap/c/30.0/00Di0000000HMr7/0DFi00000008WeE

Error:
HTTP ERROR 405

Problem accessing /services/Soap/c/30.0/00Di0000000HMr7/0DFi00000008WeE. Reason:

    GET not supported

please see the  attached error list which we got error from PI system error
 please help me on this?
i tried mass submit approval process in apex code,it's working but only one record to submit at a time.see the below code,please help me on this
for(GE_LGT_EM_ComplaintLineItem__c con:selectedContactIds)
       {
                 
             system.debug('selected cli ids---->'+con.id);--------->here getting all selected records,but only one records going to submit succesfully.i need bulk submit?
                    Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
                    req1.setComments('Mass records Submitted from visulaforce Page! ');
                    req1.setObjectId(con.id);
                    req.add(req1);
                                     
                    Approval.ProcessResult[] processResults = null;
                    try {
                    processResults = Approval.process(req, true);
                    System.debug('final result--->'+processResults);
                    }catch (System.DmlException e) {
                    System.debug('Exception Is ' + e.getMessage());
                    }
                   
                   
        }
My class 0 code coverage,urgent please help on this

my class:
public with sharing class GE_LGT_EM_ApproveRejectAllRecs
{
    List<PendingAppRecs>ProsInsts{get;set;}
    public List<ProcessInstance>prosInslist{get;set;}
    public boolean rendPgeBlock  {get;set;}
    public String pgMsg{get;set;}
    public string comments{get;set;}
    public List<GE_LGT_EM_ComplaintLineItem__c> selProsInss{get;set;}
   
    public List<ProcessInstance>  prosInsWrkItms = new List<ProcessInstance>();   
    private List<ProcessInstanceWorkitem>  prosInsWrkItms1 = new List<ProcessInstanceWorkitem>();
    public List<PendingAppRecs>  selVals = new List<PendingAppRecs>();       
    set<string>cliids=new set<string>();
    set<string>PIids=new set<string>();
    private List<Id> prosInsIds = new List<Id>();   
    public GE_LGT_EM_ApproveRejectAllRecs()
    {
        prosInslist= new List<ProcessInstance>();
        selProsInss = new List<GE_LGT_EM_ComplaintLineItem__c>();
            
        prosInslist=[Select Id, TargetObjectId, isDeleted,TargetObject.Type,Status,(Select Id, ProcessInstanceId, ActorId, Actor.Name, StepStatus, Comments From StepsAndWorkItems
                     Where StepStatus = 'Pending')From ProcessInstance Where isDeleted = false and Status = 'Pending' and TargetObject.Type='GE_LGT_EM_ComplaintLineItem__c'];
        for(ProcessInstance PIns:prosInslist){
            cliids.add(PIns.TargetObject.id);
            PIids.add(PIns.id);
            prosInsIds.add(PIns.Id);

        }
        prosInsWrkItms1 =  [SELECT Id, ProcessInstance.Id, ProcessInstance.Status, Actor.Id, Actor.Name, Actor.Type FROM ProcessInstanceWorkitem where ProcessInstance.Id in : prosInsIds];
              
   }
    public pagereference appPendingRecs()
    {
        if(!(prosInslist.size()>0))
        {
            pgMsg = 'There are no records submitted for approval.';
            rendPgeBlock  = true;
        }
        else
            rendPgeBlock  = true;
        return null;
    }
   
    public void appRej(String appRej)
    {
                     
            for(ProcessInstance  pwi :prosInslist)
            {
         
            for(GE_LGT_EM_ComplaintLineItem__c pi :selProsInss)

               {
         
                if(pwi.TargetObject.Id==pi.Id)
                {
                    Approval.ProcessWorkitemRequest req = new Approval.ProcessWorkitemRequest();
                    req.setComments(Comments);
                    req.setAction(appRej);
                    if(appRej == 'Approve')
                      // req.setNextApproverIds(new Id[] {pwi.id}); 
                        req.setNextApproverIds(null);  // No further approvals for this step needed.
     
                    List<ProcessInstanceWorkitem> procWrkItms = new List<ProcessInstanceWorkitem>();
                    procWrkItms  = [Select Id from ProcessInstanceWorkitem where ProcessInstance.Id =:pwi.id];  
                    system.debug('procWrkItms--->'+procWrkItms);                

                    if((!(procWrkItms.isEmpty()) && procWrkItms[0].Id!=null))
                    {
                      req.setWorkitemId(procWrkItms[0].Id);       
                                 
                        // Submit the request for approval   
                        Approval.ProcessResult result2 =  Approval.process(req);
                   }
                }
            }
        }
    }
   
   
    public pagereference approveAll()
    {
        system.debug('selProsInss--->'+selProsInss.size());
        system.debug('prosInsWrkItms--->'+prosInslist.size());  
        appRej('Approve');
        system.debug('appRej--->'+''); 
        Pagereference pg = new pagereference('/apex/GE_LGT_EM_BulkApproveReject');
        pg.setredirect(true);
        return pg;
    }

    public pagereference rejectAll()
    {
        appRej('Reject');
        Pagereference pg = new pagereference('/apex/GE_LGT_EM_BulkApproveReject');
        pg.setredirect(true);
        return pg;
    }

    public pagereference cancel()
    {
        Pagereference pg = new pagereference('/apex/GE_LGT_EM_BulkApproveReject');
        pg.setredirect(true);
        return pg;
    }
   
    public pagereference selRecs(){
 
            for(PendingAppRecs pendApp:ProsInsts)
            {
                if(pendApp.selected == true)
                {
                    selProsInss.add(pendApp.proInstce);
                }
            }       
            return null;
    }
 
  public List<PendingAppRecs> getProsInsts() {
   
        if (ProsInsts== null) {
            ProsInsts= new List<PendingAppRecs>();
            }
         else {
            ProsInsts.clear();
        }
       
        for(GE_LGT_EM_ComplaintLineItem__c pins : [SELECT Id,Name,GE_LGT_EM_SAPInvoiceNumber__c,GE_LGT_EM_ApprovingFunction__c,GE_LGT_EM_Category__c,GE_LGT_EM_ApprovedQuantity__c, CreatedDate FROM GE_LGT_EM_ComplaintLineItem__c where id=:cliids])
            {
             ProsInsts.add(new PendingAppRecs(pins));
            }
       
        return ProsInsts;
    }
   
    //wrapper class
    public class PendingAppRecs
    {
        public GE_LGT_EM_ComplaintLineItem__c proInstce{get; set;}
        public Boolean selected {get; set;}
     
        public PendingAppRecs(GE_LGT_EM_ComplaintLineItem__c p)
        {
        proInstce = p;
        selected = false;
       
        }
    } 
}


===============================================
my test class

@isTest(SeeAllData=true)
public class GE_LGT_EM_ApproveReject_test{
static testMethod void myUnitTest() {
   
    Test.startTest();  
        Case Caseobj=new Case(GE_LGT_EM_Salesorg__c='2BE1',Subject='test sample data');
        insert Caseobj;
       
       
        GE_LGT_EM_InvoiceLineItem__c newrec=new GE_LGT_EM_InvoiceLineItem__c(Name='testinvoicedata',CurrencyIsoCode='USD',GE_LGT_EM_CM_DM_RO_NO__c='5000');
        insert newrec;      
       
           
        GE_LGT_EM_ComplaintLineItem__c acc  = new GE_LGT_EM_ComplaintLineItem__c(GE_LGT_EM_Category__c='118-Product Mispick-Return',GE_LGT_EM_Comments__c='sample data',GE_LGT_EM_CaseNumber__c=Caseobj.id,CurrencyIsoCode='USD',GE_LGT_EM_CM_DM_RO_Number__c='500');
        insert acc ;
       
       Test.setMock(WebServiceMock.class, new GE_LGT_EM_171WebServiceMockImpl_test());
         // Create an approval request for the cli
    Approval.ProcessSubmitRequest req1 =new Approval.ProcessSubmitRequest();
    req1.setComments('Submitting request for approval.');
    req1.setObjectId(acc.id);

    // Submit the approval request for the cli
    Approval.ProcessResult result = Approval.process(req1);
  
    // Verify the result
   System.assert(result.isSuccess());

   System.assertEquals(
        'Pending', result.getInstanceStatus(),
        'Instance Status'+result.getInstanceStatus());
       
   
  // Approve the submitted request
    // First, get the ID of the newly created item
    List<Id> newWorkItemIds = result.getNewWorkitemIds();
system.debug('newWorkItemIds --->'+newWorkItemIds );
    // Instantiate the new ProcessWorkitemRequest object and populate it
    Approval.ProcessWorkitemRequest req2 =
        new Approval.ProcessWorkitemRequest();
    req2.setComments('Approving request.');
    req2.setAction('Approve');
   // req2.setNextApproverIds(new Id[] {UserInfo.getUserId()});
    req2.setNextApproverIds(new Id[] {acc.id});
    // Use the ID from the newly created item to specify the item to be worked
    req2.setWorkitemId(newWorkItemIds.get(0));

    // Submit the request for approval
    Approval.ProcessResult result2 =  Approval.process(req2);
  
    // Verify the results
system.debug('--------->'+result2);
   System.assert(result2.isSuccess(), 'Result Status:'+result2.isSuccess());

  System.assertEquals('Approved', result2.getInstanceStatus(),
     'Instance Status'+result2.getInstanceStatus());     
     Test.stopTest();
  
}    
       
   
}
  • September 15, 2014
  • Like
  • 0
System.AssertException: Assertion Failed: Instance StatusPending: Expected: Approved, Actual: Pending

My Test Class
========
@isTest(SeeAllData=true)
public class GE_LGT_EM_ApproveReject_test{
static testMethod void myUnitTest() {
    // Insert an account
        Case Caseobj=new Case(GE_LGT_EM_Salesorg__c='2BE1',Subject='test sample data');
        insert Caseobj;
       
       
        GE_LGT_EM_InvoiceLineItem__c newrec=new GE_LGT_EM_InvoiceLineItem__c(Name='testinvoicedata',CurrencyIsoCode='USD',GE_LGT_EM_CM_DM_RO_NO__c='5000');
        insert newrec;      
       
           
        GE_LGT_EM_ComplaintLineItem__c acc  = new GE_LGT_EM_ComplaintLineItem__c(GE_LGT_EM_Category__c='118-Product Mispick-Return',GE_LGT_EM_Comments__c='sample data',GE_LGT_EM_CaseNumber__c=Caseobj.id,CurrencyIsoCode='USD',GE_LGT_EM_CM_DM_RO_Number__c='500');
        insert acc ;
       
       Test.setMock(WebServiceMock.class, new GE_LGT_EM_171WebServiceMockImpl_test());
         // Create an approval request for the cli
    Approval.ProcessSubmitRequest req1 =new Approval.ProcessSubmitRequest();
    req1.setComments('Submitting request for approval.');
    req1.setObjectId(acc.id);

    // Submit the approval request for the cli
    Approval.ProcessResult result = Approval.process(req1);

    // Verify the result
    System.assert(result.isSuccess());

    System.assertEquals(
        'Pending', result.getInstanceStatus(),
        'Instance Status'+result.getInstanceStatus());
       
       
  // Approve the submitted request
    // First, get the ID of the newly created item
    List<Id> newWorkItemIds = result.getNewWorkitemIds();

    // Instantiate the new ProcessWorkitemRequest object and populate it
    Approval.ProcessWorkitemRequest req2 =
        new Approval.ProcessWorkitemRequest();
    req2.setComments('Approving request.');
    req2.setAction('Approve');
    req2.setNextApproverIds(new Id[] {UserInfo.getUserId()});

    // Use the ID from the newly created item to specify the item to be worked
    req2.setWorkitemId(newWorkItemIds.get(0));

    // Submit the request for approval
    Approval.ProcessResult result2 =  Approval.process(req2);

    // Verify the results
   
   

   
    System.assert(result2.isSuccess(), 'Result Status:'+result2.isSuccess());

    System.assertEquals('Approved', result2.getInstanceStatus(),   //here getting error
      'Instance Status'+result2.getInstanceStatus());     

      
  
}    
       
   
}
}
please help me on this

  • September 15, 2014
  • Like
  • 0
I have account trigger see below,i tried to optimize trigger code,no luck?.
i made bold text for error line,through data loader bulk account data inserting then this trigger should be fire.
please help me on this?

trigger GE_LGT_EM_AvoidDuplicateAccount on Account (after insert,after update) {

Map<id, String> AccountMap = new Map<id, String>();
Map<id, String> AccountMapSalesorg = new Map<id, String>();
Map<id, String> AccountMapDivision = new Map<id, String>();
Map<id,account> updateacc = new Map<id,Account>();
set<string> deletedupeaccount = new set<string>();
set<id>newaccountids=new set<id>();
set<id>newduplicate=new set<id>();
List<recordtype> rt=[select id,name from recordtype where sobjecttype='Account' and name='EMEA Account'];

if(trigger.isinsert ){
     for (Account acc :Trigger.new) {
     
                if(acc.GE_LGT_EM_SAP_Customer_Number__c !=null && acc.RecordTypeid==rt[0].id ) {
                AccountMap.put(acc.id,acc.GE_LGT_EM_SAP_Customer_Number__c);//collect all new customernumber
                AccountMapSalesorg.put(acc.id,acc.GE_LGT_EM_Sales_Org__c);
                AccountMapDivision.put(acc.id,acc.GE_LGT_EM_Division__c);
                newaccountids.add(acc.id);//collect all new ids
                system.debug('newaccountids----->'+newaccountids);
                }
            }
        }
   
//find the same customer number already exist or not in system

list<account> Dupeacclist=[SELECT id,Name,GE_LGT_EM_Partner_Function__c,BillingStreet,GE_LGT_EM_Sales_Org__c,GE_LGT_EM_Division__c,BillingCity,BillingState,BillingPostalCode,GE_LGT_EM_CustomerActiveFlag__c,GE_LGT_EM_Tax_Number_1__c,GE_LGT_EM_Tax_Number_2__c,CurrencyIsoCode,GE_LGT_EM_Plant__c,GE_LGT_EM_PF_Type__c,GE_LGT_EM_SAP_Customer_Number__c FROM Account
     WHERE id NOT IN:newaccountids and RecordTypeid=:rt[0].id and
     GE_LGT_EM_SAP_Customer_Number__c IN:AccountMap.values()and
     GE_LGT_EM_Sales_Org__c IN:AccountMapSalesorg.values()and
     GE_LGT_EM_Division__c IN:AccountMapDivision.values()];

     system.debug('already dupe in system newaccountids----->'+Dupeacclist);

 
for(Account c:trigger.new)
{
      for(Account acct:Dupeacclist) {
     
          if(c.RecordTypeid==rt[0].id && c.GE_LGT_EM_SAP_Customer_Number__c ==acct.GE_LGT_EM_SAP_Customer_Number__c && c.GE_LGT_EM_Sales_Org__c==acct.GE_LGT_EM_Sales_Org__c && c.GE_LGT_EM_Division__c==acct.GE_LGT_EM_Division__c) {
                acct.Name=c.Name;
                acct.GE_LGT_EM_Partner_Function__c=c.GE_LGT_EM_Partner_Function__c;
                acct.BillingStreet=c.BillingStreet;
                acct.BillingCity=c.BillingCity;
                acct.BillingState=c.BillingState;
                acct.BillingPostalCode=c.BillingPostalCode;
                acct.GE_LGT_EM_CustomerActiveFlag__c=c.GE_LGT_EM_CustomerActiveFlag__c;
                acct.GE_LGT_EM_Tax_Number_1__c=c.GE_LGT_EM_Tax_Number_1__c;
                acct.GE_LGT_EM_Tax_Number_2__c=c.GE_LGT_EM_Tax_Number_2__c;
                acct.CurrencyIsoCode=c.CurrencyIsoCode;
                acct.GE_LGT_EM_Plant__c=c.GE_LGT_EM_Plant__c;
                acct.GE_LGT_EM_PF_Type__c=c.GE_LGT_EM_PF_Type__c;
                updateacc.put(acct.id,acct);
                newduplicate.add(c.id);
                system.debug('newduplicate----->'+newduplicate);
         }
     }
}

     if(updateacc.size()>0){
            system.debug('----------->update final');
            update updateacc.values(); 
        }
       
if(newduplicate.size()>0){
    GE_LGT_EM_deleteduplicateaccount.Dupdeleteaccount(newduplicate);
    }

}
  • September 09, 2014
  • Like
  • 0
For Example:java script result getting below format like that,
var result=sdfsd,sdfsdf,sfsdfsd,sfsdfsd,ertert
this values need add my options below format
sdfsd
sdfsdf
sfsdfsd
sfsdfsd
ertert
see my attached screen what i got result.
User-added image

my javascript code
===============
<script type="text/javascript">
  
function selectPosition(id){

var pos1 = document.getElementById(id).value;

Visualforce.remoting.Manager.invokeAction(
            '{!$RemoteAction.AccountRemoter.getRemotePieData}',
            pos1,
         function(result, event){
      
                if (event.status && result.constructor === Array) {
                  
                        var opt = result.length;
                         var ListOfopt = result;
                         alert(ListOfopt);
                var str2 =  new Array(ListOfopt);
                   alert(str2);
                  
    
       
   
          var x = document.getElementById("mySelect");
                       
                        var option = document.createElement("option");
                       
                        option.text = result;
                       
                        x.add(option);
      
                 
                      
                     
                } else if (event.type === 'exception') {
                    document.getElementById("responseErrors").innerHTML =
                        event.message + "<br/>\n<pre>" + event.where + "</pre>";
                } else {
                    document.getElementById("responseErrors").innerHTML = event.message;
                }
            },
            {escape: true}
        );
         document.getElementById("mySelect").options.length=0
}
    </script>

please anyone help on this
if found duplicates records based on customer number field unique,so update to exiting record and new record need to delete?please help me on this

trigger GE_LGT_EM_AvoidDuplicateAccount on Account (before insert,before update) {

    Map<String, Account> AccountMap = new Map<String, Account>();
    set<string> deleteAccountMap = new set<string>();
    Map<id,account>updateacc=new Map<id,Account>();
    List<recordtype> rt=[select id,name from recordtype where sobjecttype='Account' and name='EMEA Account'];
        for (Account acc :System.Trigger.new)
        {
        if ((acc.GE_LGT_EM_SAP_Customer_Number__c != null) && acc.RecordTypeid==rt[0].id && (System.Trigger.isInsert ))
        AccountMap.put(acc.GE_LGT_EM_SAP_Customer_Number__c, acc);
         deleteAccountMap.add(acc.id);
        }
      
    list<account> acclist=[SELECT id,
    Name,
    GE_LGT_EM_Partner_Function__c,
    BillingStreet,
    BillingCity,
    BillingState,
    BillingPostalCode,
    GE_LGT_EM_CustomerActiveFlag__c,
    GE_LGT_EM_Tax_Number_1__c,
    GE_LGT_EM_Tax_Number_2__c,
    CurrencyIsoCode,
    GE_LGT_EM_Plant__c,
    GE_LGT_EM_PF_Type__c,
    GE_LGT_EM_SAP_Customer_Number__c FROM Account WHERE RecordTypeid=:rt[0].id and GE_LGT_EM_SAP_Customer_Number__c IN:AccountMap.KeySet()];
        system.debug('-------->acclist'+acclist);
        for(Account c :Trigger.new)
        {
            for(Account acct:acclist)
           {
           system.debug('----------->inside for loop');
               if(c.GE_LGT_EM_SAP_Customer_Number__c==acct.GE_LGT_EM_SAP_Customer_Number__c && AccountMap.containsKey(c.GE_LGT_EM_SAP_Customer_Number__c) && c.RecordTypeid==rt[0].id)
                {
                    acct.Name=c.Name;
                    acct.GE_LGT_EM_Partner_Function__c=c.GE_LGT_EM_Partner_Function__c;
                    acct.BillingStreet=c.BillingStreet;
                    acct.BillingCity=c.BillingCity;
                    acct.BillingState=c.BillingState;
                    acct.BillingPostalCode=c.BillingPostalCode;
                    acct.GE_LGT_EM_CustomerActiveFlag__c=c.GE_LGT_EM_CustomerActiveFlag__c;
                    acct.GE_LGT_EM_Tax_Number_1__c=c.GE_LGT_EM_Tax_Number_1__c;
                    acct.GE_LGT_EM_Tax_Number_2__c=c.GE_LGT_EM_Tax_Number_2__c;
                    acct.CurrencyIsoCode=c.CurrencyIsoCode;
                    acct.GE_LGT_EM_Plant__c=c.GE_LGT_EM_Plant__c;
                    acct.GE_LGT_EM_PF_Type__c=c.GE_LGT_EM_PF_Type__c;
                    updateacc.put(acct.id,acct);
                }
                        
            }      
        }
   
   if(updateacc.size()>0){
     system.debug('----------->update final');
   update updateacc.values();
   }
  
  /**************delete duplicate account**************/
   set<string> uniqueIds = new set<string>();

    for (Account s : Trigger.new)
        uniqueIds.add(s.GE_LGT_EM_SAP_Customer_Number__c);

    list<Account> existingAccounts = [select id,GE_LGT_EM_SAP_Customer_Number__c from Account where GE_LGT_EM_SAP_Customer_Number__c in :uniqueIds and RecordTypeid=:rt[0].id];

    list<Account> dupestodelete = new list<Account>();
    for (Account s : Trigger.new)
    {
        for (Account existing : existingAccounts)
        {
            if (s.GE_LGT_EM_SAP_Customer_Number__c == existing.GE_LGT_EM_SAP_Customer_Number__c )
            {
                dupestodelete.add(s);
                continue;
            }
        }
    }

    delete dupestodelete;

}

System.CalloutException: IO Exception: Detect premature EOF

 

please help me anyone on this...

thanks in advance..

System.CalloutException: IO Exception: Detect premature EOF

 

please help me anyone on this...

thanks in advance..

System.CalloutException: IO Exception: Detect premature EOF

 

please help me on this

thanks

Error: Compile Error: Method
does not exist or incorrect signature:
[gelightingComCom433Crdbmemorequest.SI_SFDC_CrDbMemoRequest_433_OB_ASYNCPort].RecordSet(LIST<GE_LGT_EM_ComplaintLineItem__c>)
at line 31 column 5
=======================apex class=========
public class GE_LGT_EM_SAPWebservice{

public gelightingComCom433Crdbmemorequest.RecordSet_element[] RecordSet;
//public gelightingComCom433Crdbmemorequest.RecordSet_element[] SI_SFDC_CrDbMemoRequest_433_OB_ASYNC;
@future(callout = true)
    public static void SfdcTOSapwebservice(set<string>cid)
    {
    string GELGT_result;
    list<GE_LGT_EM_ComplaintLineItem__c>CLIObjList=[select Name,
    GE_LGT_EM_ApprovedQuantity__c,
    GE_LGT_EM_ApprovedUnitPrice__c,
    GE_LGT_EM_Block_CR__c,
    GE_LGT_EM_Doc_Type__c,
    GE_LGT_EM_Material_Number__c,
    GE_LGT_EM_Rejection_Code__c,
    GE_LGT_EM_Sales_Org__c,
    GE_LGT_EM_SAPInvoiceNumber__c
     from GE_LGT_EM_ComplaintLineItem__c where Id=:cid];
   // string[] complineitemset;
  GE_LGT_EM_ComplaintLineItem__c[] slist=new GE_LGT_EM_ComplaintLineItem__c[0];

    for(GE_LGT_EM_ComplaintLineItem__c cli:CLIObjList)
    {
    slist.add(cli);
   }
     system.debug('listobj------>'+slist);
    //call your webservice method and pass all parameters to it
    
   

gelightingComCom433Crdbmemorequest.SI_SFDC_CrDbMemoRequest_433_OB_ASYNCPort
GELGTmainclass = new
gelightingComCom433Crdbmemorequest.SI_SFDC_CrDbMemoRequest_433_OB_ASYNCPort();
    system.debug('main class------>'+GELGTmainclass );
    GELGTmainclass.RecordSet(slist); ---here getting error

  
    }
}

=============================
//Generated by wsdl2apex

public class gelightingComCom433Crdbmemorequest {
    public class RecordSet_element {
        public String ComplaintNumber;
        public String ComplaintLineItemNo;
        public String SAPInvoiceNumber;
        public String SAPInvoiceLineItemNo;
        public String ApprovedQuantity;
        public String ApprovedPrice;
        public String SAPCustomerNumber;
        public String DocType;
        public String CategoryCode;
        public String SalesOrg;
        public String Division;
        public String DistributionChannel;
        public String RejectCode;
        public String BlockCR;
        public String MaterialNumber;
       
private String[] ComplaintNumber_type_info = new
String[]{'ComplaintNumber','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] ComplaintLineItemNo_type_info = new
String[]{'ComplaintLineItemNo','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] SAPInvoiceNumber_type_info = new
String[]{'SAPInvoiceNumber','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] SAPInvoiceLineItemNo_type_info = new
String[]{'SAPInvoiceLineItemNo','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] ApprovedQuantity_type_info = new
String[]{'ApprovedQuantity','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] ApprovedPrice_type_info = new
String[]{'ApprovedPrice','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] SAPCustomerNumber_type_info = new
String[]{'SAPCustomerNumber','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] DocType_type_info = new
String[]{'DocType','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] CategoryCode_type_info = new
String[]{'CategoryCode','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] SalesOrg_type_info = new
String[]{'SalesOrg','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] Division_type_info = new
String[]{'Division','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] DistributionChannel_type_info = new
String[]{'DistributionChannel','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] RejectCode_type_info = new
String[]{'RejectCode','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] BlockCR_type_info = new
String[]{'BlockCR','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] MaterialNumber_type_info = new
String[]{'MaterialNumber','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:gelighting.com:COM_433:CrDbMemoRequest','false','false'};
       
private String[] field_order_type_info = new
String[]{'ComplaintNumber','ComplaintLineItemNo','SAPInvoiceNumber','SAPInvoiceLineItemNo','ApprovedQuantity','ApprovedPrice','SAPCustomerNumber','DocType','CategoryCode','SalesOrg','Division','DistributionChannel','RejectCode','BlockCR','MaterialNumber'};
    }
    public class DT_SFDC_CrDbMemoRequest {
        public gelightingComCom433Crdbmemorequest.RecordSet_element[] RecordSet;
       
private String[] RecordSet_type_info = new
String[]{'RecordSet','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','-1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:gelighting.com:COM_433:CrDbMemoRequest','false','false'};
        private String[] field_order_type_info = new String[]{'RecordSet'};
    }
    public class SI_SFDC_CrDbMemoRequest_433_OB_ASYNCPort {
       
public String endpoint_x =
'http://lxv2000.light.ge.com:50200/XISOAPAdapter/MessageServlet?channel=:BC_SFDC:COM_433_SFDC_CrDbMemoRequest_SOAP_SCC&version=3.0&Sender.Service=BC_SFDC&Interface=urn%3Agelighting.com%3ACOM_433%3ACrDbMemoRequest%5ESI_SFDC_CrDbMemoRequest_433_OB_ASYNC';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
       
private String[] ns_map_type_info = new
String[]{'urn:gelighting.com:COM_433:CrDbMemoRequest',
'gelightingComCom433Crdbmemorequest'};
        public
gelightingComCom433Crdbmemorequest.RecordSet_element[]
SI_SFDC_CrDbMemoRequest_433_OB_ASYNC(gelightingComCom433Crdbmemorequest.RecordSet_element[]
RecordSet) {
           
gelightingComCom433Crdbmemorequest.DT_SFDC_CrDbMemoRequest request_x =
new gelightingComCom433Crdbmemorequest.DT_SFDC_CrDbMemoRequest();
            gelightingComCom433Crdbmemorequest.DT_SFDC_CrDbMemoRequest response_x;
            request_x.RecordSet = RecordSet;
           
Map<String,
gelightingComCom433Crdbmemorequest.DT_SFDC_CrDbMemoRequest>
response_map_x = new Map<String,
gelightingComCom433Crdbmemorequest.DT_SFDC_CrDbMemoRequest>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://sap.com/xi/WebService/soap1.1',
              'urn:gelighting.com:COM_433:CrDbMemoRequest',
              'MT_SFDC_CrDbMemoRequest',
              'urn:gelighting.com:COM_433:CrDbMemoRequest',
              'MT_SFDC_CrDbMemoRequest',
              'gelightingComCom433Crdbmemorequest.DT_SFDC_CrDbMemoRequest'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.RecordSet;
        }
    }
}

Error: Compile Error: Method
does not exist or incorrect signature:
[gelightingComCom433Crdbmemorequest.SI_SFDC_CrDbMemoRequest_433_OB_ASYNCPort].RecordSet(LIST<GE_LGT_EM_ComplaintLineItem__c>)
at line 31 column 5
=======================apex class=========
public class GE_LGT_EM_SAPWebservice{

public gelightingComCom433Crdbmemorequest.RecordSet_element[] RecordSet;
//public gelightingComCom433Crdbmemorequest.RecordSet_element[] SI_SFDC_CrDbMemoRequest_433_OB_ASYNC;
@future(callout = true)
    public static void SfdcTOSapwebservice(set<string>cid)
    {
    string GELGT_result;
    list<GE_LGT_EM_ComplaintLineItem__c>CLIObjList=[select Name,
    GE_LGT_EM_ApprovedQuantity__c,
    GE_LGT_EM_ApprovedUnitPrice__c,
    GE_LGT_EM_Block_CR__c,
    GE_LGT_EM_Doc_Type__c,
    GE_LGT_EM_Material_Number__c,
    GE_LGT_EM_Rejection_Code__c,
    GE_LGT_EM_Sales_Org__c,
    GE_LGT_EM_SAPInvoiceNumber__c
     from GE_LGT_EM_ComplaintLineItem__c where Id=:cid];
   // string[] complineitemset;
  GE_LGT_EM_ComplaintLineItem__c[] slist=new GE_LGT_EM_ComplaintLineItem__c[0];

    for(GE_LGT_EM_ComplaintLineItem__c cli:CLIObjList)
    {
    slist.add(cli);
   }
     system.debug('listobj------>'+slist);
    //call your webservice method and pass all parameters to it
    
   

gelightingComCom433Crdbmemorequest.SI_SFDC_CrDbMemoRequest_433_OB_ASYNCPort
GELGTmainclass = new
gelightingComCom433Crdbmemorequest.SI_SFDC_CrDbMemoRequest_433_OB_ASYNCPort();
    system.debug('main class------>'+GELGTmainclass );
    GELGTmainclass.RecordSet(slist); ---here getting error

  
    }
}

=============================
//Generated by wsdl2apex

public class gelightingComCom433Crdbmemorequest {
    public class RecordSet_element {
        public String ComplaintNumber;
        public String ComplaintLineItemNo;
        public String SAPInvoiceNumber;
        public String SAPInvoiceLineItemNo;
        public String ApprovedQuantity;
        public String ApprovedPrice;
        public String SAPCustomerNumber;
        public String DocType;
        public String CategoryCode;
        public String SalesOrg;
        public String Division;
        public String DistributionChannel;
        public String RejectCode;
        public String BlockCR;
        public String MaterialNumber;
       
private String[] ComplaintNumber_type_info = new
String[]{'ComplaintNumber','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] ComplaintLineItemNo_type_info = new
String[]{'ComplaintLineItemNo','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] SAPInvoiceNumber_type_info = new
String[]{'SAPInvoiceNumber','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] SAPInvoiceLineItemNo_type_info = new
String[]{'SAPInvoiceLineItemNo','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] ApprovedQuantity_type_info = new
String[]{'ApprovedQuantity','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] ApprovedPrice_type_info = new
String[]{'ApprovedPrice','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] SAPCustomerNumber_type_info = new
String[]{'SAPCustomerNumber','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] DocType_type_info = new
String[]{'DocType','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] CategoryCode_type_info = new
String[]{'CategoryCode','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] SalesOrg_type_info = new
String[]{'SalesOrg','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] Division_type_info = new
String[]{'Division','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] DistributionChannel_type_info = new
String[]{'DistributionChannel','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] RejectCode_type_info = new
String[]{'RejectCode','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] BlockCR_type_info = new
String[]{'BlockCR','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
       
private String[] MaterialNumber_type_info = new
String[]{'MaterialNumber','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:gelighting.com:COM_433:CrDbMemoRequest','false','false'};
       
private String[] field_order_type_info = new
String[]{'ComplaintNumber','ComplaintLineItemNo','SAPInvoiceNumber','SAPInvoiceLineItemNo','ApprovedQuantity','ApprovedPrice','SAPCustomerNumber','DocType','CategoryCode','SalesOrg','Division','DistributionChannel','RejectCode','BlockCR','MaterialNumber'};
    }
    public class DT_SFDC_CrDbMemoRequest {
        public gelightingComCom433Crdbmemorequest.RecordSet_element[] RecordSet;
       
private String[] RecordSet_type_info = new
String[]{'RecordSet','urn:gelighting.com:COM_433:CrDbMemoRequest',null,'0','-1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:gelighting.com:COM_433:CrDbMemoRequest','false','false'};
        private String[] field_order_type_info = new String[]{'RecordSet'};
    }
    public class SI_SFDC_CrDbMemoRequest_433_OB_ASYNCPort {
       
public String endpoint_x =
'http://lxv2000.light.ge.com:50200/XISOAPAdapter/MessageServlet?channel=:BC_SFDC:COM_433_SFDC_CrDbMemoRequest_SOAP_SCC&version=3.0&Sender.Service=BC_SFDC&Interface=urn%3Agelighting.com%3ACOM_433%3ACrDbMemoRequest%5ESI_SFDC_CrDbMemoRequest_433_OB_ASYNC';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
       
private String[] ns_map_type_info = new
String[]{'urn:gelighting.com:COM_433:CrDbMemoRequest',
'gelightingComCom433Crdbmemorequest'};
        public
gelightingComCom433Crdbmemorequest.RecordSet_element[]
SI_SFDC_CrDbMemoRequest_433_OB_ASYNC(gelightingComCom433Crdbmemorequest.RecordSet_element[]
RecordSet) {
           
gelightingComCom433Crdbmemorequest.DT_SFDC_CrDbMemoRequest request_x =
new gelightingComCom433Crdbmemorequest.DT_SFDC_CrDbMemoRequest();
            gelightingComCom433Crdbmemorequest.DT_SFDC_CrDbMemoRequest response_x;
            request_x.RecordSet = RecordSet;
           
Map<String,
gelightingComCom433Crdbmemorequest.DT_SFDC_CrDbMemoRequest>
response_map_x = new Map<String,
gelightingComCom433Crdbmemorequest.DT_SFDC_CrDbMemoRequest>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://sap.com/xi/WebService/soap1.1',
              'urn:gelighting.com:COM_433:CrDbMemoRequest',
              'MT_SFDC_CrDbMemoRequest',
              'urn:gelighting.com:COM_433:CrDbMemoRequest',
              'MT_SFDC_CrDbMemoRequest',
              'gelightingComCom433Crdbmemorequest.DT_SFDC_CrDbMemoRequest'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.RecordSet;
        }
    }
}

i have javascipt button "MassEmail" in campaign detail page,when we click the button send the email to all related campign members.In this purpose i have created one Html email template for campaign objects.But in email template i am not able display"detail page link".
========
Javascript code
==========
{!REQUIRESCRIPT('/soap/ajax/26.0/connection.js')} 
{!REQUIRESCRIPT('/js/functions.js')} 
{!REQUIRESCRIPT('/resource/Rfleet_JqyeryUI_STR/jquery1/js/jquery-1.8.3.js')} 
{!REQUIRESCRIPT('/resource/Rfleet_JqyeryUI_STR/jquery1/js/jquery-ui-1.9.2.custom.min.js')} 

var Contactids=[]; 
var recordname=[]; 
var emailids=[]; 
var contactname=[]; 

var CamMember=sforce.connection.query("SELECT CampaignId,ContactId FROM CampaignMember where CampaignId='{!Campaign.Id}'"); 
var records = CamMember.getArray("records"); 

for (var i=0; i<records.length; i++) { 
recordname = records[i]; 
Contactids.push(recordname.ContactId); 



var con=sforce.connection.query('SELECT Id,Email '+'FROM Contact where id in (\'' + Contactids.join('\',\'') + '\')'); 

var contactemail = con.getArray("records"); 

for (var i=0; i<contactemail.length; i++) { 
contactname = contactemail[i]; 
emailids.push(contactname.Id); 



for (var i=0; i<emailids.length; i++) { 

var message = new sforce.SingleEmailMessage(); 
message.replyTo = "rapsac@gmail.com"; 
message.targetObjectId=emailids[i]; 
message.templateId ="00X4E000000EMXt"; 
var result = sforce.connection.sendEmail([message]); 

if(result[0].success == 'true') { 
alert("I sent the email as you requested, master."); 
} else { 
alert("I had a booboo."); 
}
==========
email template
========
User-added image

Advanced thanks for helping:)
System.AssertException: Assertion Failed: Instance StatusPending: Expected: Approved, Actual: Pending

My Test Class
========
@isTest(SeeAllData=true)
public class GE_LGT_EM_ApproveReject_test{
static testMethod void myUnitTest() {
    // Insert an account
        Case Caseobj=new Case(GE_LGT_EM_Salesorg__c='2BE1',Subject='test sample data');
        insert Caseobj;
       
       
        GE_LGT_EM_InvoiceLineItem__c newrec=new GE_LGT_EM_InvoiceLineItem__c(Name='testinvoicedata',CurrencyIsoCode='USD',GE_LGT_EM_CM_DM_RO_NO__c='5000');
        insert newrec;      
       
           
        GE_LGT_EM_ComplaintLineItem__c acc  = new GE_LGT_EM_ComplaintLineItem__c(GE_LGT_EM_Category__c='118-Product Mispick-Return',GE_LGT_EM_Comments__c='sample data',GE_LGT_EM_CaseNumber__c=Caseobj.id,CurrencyIsoCode='USD',GE_LGT_EM_CM_DM_RO_Number__c='500');
        insert acc ;
       
       Test.setMock(WebServiceMock.class, new GE_LGT_EM_171WebServiceMockImpl_test());
         // Create an approval request for the cli
    Approval.ProcessSubmitRequest req1 =new Approval.ProcessSubmitRequest();
    req1.setComments('Submitting request for approval.');
    req1.setObjectId(acc.id);

    // Submit the approval request for the cli
    Approval.ProcessResult result = Approval.process(req1);

    // Verify the result
    System.assert(result.isSuccess());

    System.assertEquals(
        'Pending', result.getInstanceStatus(),
        'Instance Status'+result.getInstanceStatus());
       
       
  // Approve the submitted request
    // First, get the ID of the newly created item
    List<Id> newWorkItemIds = result.getNewWorkitemIds();

    // Instantiate the new ProcessWorkitemRequest object and populate it
    Approval.ProcessWorkitemRequest req2 =
        new Approval.ProcessWorkitemRequest();
    req2.setComments('Approving request.');
    req2.setAction('Approve');
    req2.setNextApproverIds(new Id[] {UserInfo.getUserId()});

    // Use the ID from the newly created item to specify the item to be worked
    req2.setWorkitemId(newWorkItemIds.get(0));

    // Submit the request for approval
    Approval.ProcessResult result2 =  Approval.process(req2);

    // Verify the results
   
   

   
    System.assert(result2.isSuccess(), 'Result Status:'+result2.isSuccess());

    System.assertEquals('Approved', result2.getInstanceStatus(),   //here getting error
      'Instance Status'+result2.getInstanceStatus());     

      
  
}    
       
   
}
}
please help me on this

  • September 15, 2014
  • Like
  • 0
For Example:java script result getting below format like that,
var result=sdfsd,sdfsdf,sfsdfsd,sfsdfsd,ertert
this values need add my options below format
sdfsd
sdfsdf
sfsdfsd
sfsdfsd
ertert
see my attached screen what i got result.
User-added image

my javascript code
===============
<script type="text/javascript">
  
function selectPosition(id){

var pos1 = document.getElementById(id).value;

Visualforce.remoting.Manager.invokeAction(
            '{!$RemoteAction.AccountRemoter.getRemotePieData}',
            pos1,
         function(result, event){
      
                if (event.status && result.constructor === Array) {
                  
                        var opt = result.length;
                         var ListOfopt = result;
                         alert(ListOfopt);
                var str2 =  new Array(ListOfopt);
                   alert(str2);
                  
    
       
   
          var x = document.getElementById("mySelect");
                       
                        var option = document.createElement("option");
                       
                        option.text = result;
                       
                        x.add(option);
      
                 
                      
                     
                } else if (event.type === 'exception') {
                    document.getElementById("responseErrors").innerHTML =
                        event.message + "<br/>\n<pre>" + event.where + "</pre>";
                } else {
                    document.getElementById("responseErrors").innerHTML = event.message;
                }
            },
            {escape: true}
        );
         document.getElementById("mySelect").options.length=0
}
    </script>

please anyone help on this
if found duplicates records based on customer number field unique,so update to exiting record and new record need to delete?please help me on this

trigger GE_LGT_EM_AvoidDuplicateAccount on Account (before insert,before update) {

    Map<String, Account> AccountMap = new Map<String, Account>();
    set<string> deleteAccountMap = new set<string>();
    Map<id,account>updateacc=new Map<id,Account>();
    List<recordtype> rt=[select id,name from recordtype where sobjecttype='Account' and name='EMEA Account'];
        for (Account acc :System.Trigger.new)
        {
        if ((acc.GE_LGT_EM_SAP_Customer_Number__c != null) && acc.RecordTypeid==rt[0].id && (System.Trigger.isInsert ))
        AccountMap.put(acc.GE_LGT_EM_SAP_Customer_Number__c, acc);
         deleteAccountMap.add(acc.id);
        }
      
    list<account> acclist=[SELECT id,
    Name,
    GE_LGT_EM_Partner_Function__c,
    BillingStreet,
    BillingCity,
    BillingState,
    BillingPostalCode,
    GE_LGT_EM_CustomerActiveFlag__c,
    GE_LGT_EM_Tax_Number_1__c,
    GE_LGT_EM_Tax_Number_2__c,
    CurrencyIsoCode,
    GE_LGT_EM_Plant__c,
    GE_LGT_EM_PF_Type__c,
    GE_LGT_EM_SAP_Customer_Number__c FROM Account WHERE RecordTypeid=:rt[0].id and GE_LGT_EM_SAP_Customer_Number__c IN:AccountMap.KeySet()];
        system.debug('-------->acclist'+acclist);
        for(Account c :Trigger.new)
        {
            for(Account acct:acclist)
           {
           system.debug('----------->inside for loop');
               if(c.GE_LGT_EM_SAP_Customer_Number__c==acct.GE_LGT_EM_SAP_Customer_Number__c && AccountMap.containsKey(c.GE_LGT_EM_SAP_Customer_Number__c) && c.RecordTypeid==rt[0].id)
                {
                    acct.Name=c.Name;
                    acct.GE_LGT_EM_Partner_Function__c=c.GE_LGT_EM_Partner_Function__c;
                    acct.BillingStreet=c.BillingStreet;
                    acct.BillingCity=c.BillingCity;
                    acct.BillingState=c.BillingState;
                    acct.BillingPostalCode=c.BillingPostalCode;
                    acct.GE_LGT_EM_CustomerActiveFlag__c=c.GE_LGT_EM_CustomerActiveFlag__c;
                    acct.GE_LGT_EM_Tax_Number_1__c=c.GE_LGT_EM_Tax_Number_1__c;
                    acct.GE_LGT_EM_Tax_Number_2__c=c.GE_LGT_EM_Tax_Number_2__c;
                    acct.CurrencyIsoCode=c.CurrencyIsoCode;
                    acct.GE_LGT_EM_Plant__c=c.GE_LGT_EM_Plant__c;
                    acct.GE_LGT_EM_PF_Type__c=c.GE_LGT_EM_PF_Type__c;
                    updateacc.put(acct.id,acct);
                }
                        
            }      
        }
   
   if(updateacc.size()>0){
     system.debug('----------->update final');
   update updateacc.values();
   }
  
  /**************delete duplicate account**************/
   set<string> uniqueIds = new set<string>();

    for (Account s : Trigger.new)
        uniqueIds.add(s.GE_LGT_EM_SAP_Customer_Number__c);

    list<Account> existingAccounts = [select id,GE_LGT_EM_SAP_Customer_Number__c from Account where GE_LGT_EM_SAP_Customer_Number__c in :uniqueIds and RecordTypeid=:rt[0].id];

    list<Account> dupestodelete = new list<Account>();
    for (Account s : Trigger.new)
    {
        for (Account existing : existingAccounts)
        {
            if (s.GE_LGT_EM_SAP_Customer_Number__c == existing.GE_LGT_EM_SAP_Customer_Number__c )
            {
                dupestodelete.add(s);
                continue;
            }
        }
    }

    delete dupestodelete;

}

System.CalloutException: IO Exception: Detect premature EOF

 

please help me on this

thanks

what i doing now is,i have written custom webservice and gave to sap team.we are planning connect salesforce system using  SSL certificate for mutual authentication.
my question is how to pass the certificate parameter with in custom webservices?
becoz they do not want use login credencials and other thing is SAP side there is no option to parse our WSDL.
so how to handshake our system through CUSTOM WSDL?