• Vasundhara Velgoti 4
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 6
    Replies
We are getting flow error when an integration user runs a script( C sharp code) from his environment, to insert or update data into Salesforce. Can anyone suggest us where would be the error and the resolution Please? It is a high priority task for us now
Hi ,

Below is the trigger :
trigger POTriggerUpdate on PurchaseOrder__c (after insert, after update) {
    
     //Creating Project Plan in PurchaseOrder__c
    
     if(((trigger.isUpdate) && trigger.isAfter) || test.isRunningTest())
    {
       
    try
     {
      
           POTriggerLogic.afterInsertAfterUpdateLogic(trigger.new,trigger.oldMap,true);  
      }
      catch(DMLException e)
      {
         
      trigger.new[0].addError('Updation not possible because '+ e.getMessage());
          
     }
        
    }
    //End of Update Project plan in PurchaseOrder__c 

}

Test class:
@isTest
public class Test_POTriggerUpdate {
    
     @isTest static void unittest(){
        Test.startTest();
        try
        {
           
          Krow__Project__c kp = new Krow__Project__c();
          kp.Id=kp.Id;
       
        insert kp;
        Krow__Task__c kt = new Krow__Task__c();
        kt.Id=kt.Id;
        kt.Name='test';
        kt.Krow__Start_Date__c = Date.today();
        kt.Krow__Due_Date__c   = Date.today();
        kt.Krow__Project__c    = kp.Id;
        
        kt.Krow__Parent_Task__c= null;
        kt.Actual_Due_Date__c  = null;
        kt.Krow__Project_Phase__c=false;
        kt.Create_Task_Assignment__c=true;
        insert kt;
           PurchaseOrder__c po                                   =  new PurchaseOrder__c();
                          
                          po.Name                              = 'Test order'; 
                           po.Status__c                         = 'Draft';
                          po.Engagement_Plan_Create__c         = false;
                          po.Engagement_Plan_Template__c       = kp.Id;
                          po.Engagement_Plan_Update__c         = false;
                          po.Engagement_Plan_Update_Template__c= kp.Id;
                         // po.Engagement_Plan__c                = opp.Engagement_Plan__c;
                   insert po;
                          po.Name                              = 'Test order1';
                         
                          po.Status__c                         = 'GM Approval Pending';
                          po.Engagement_Plan_Create__c         =  true;
                          po.Engagement_Plan_Update__c         = true;
                          po.Engagement_Plan_Template__c       = kp.Id;
                          po.Engagement_Plan_Update_Template__c= kp.Id;
                          //po.Engagement_Plan__c                = null;
                 

       
       
        }
        catch(Exception e) {
            Boolean expectedError=  e.getMessage().contains('Updation not possible because') ? true : false;
         System.AssertEquals(expectedError, true); 
        }
        Test.stopTest();
             
        /* Opportunity opp                                       =  new Opportunity();
                    opp.Name                                   = 'Test Opp';
                    opp.StageName                              = 'Target'; 
                    opp.Engagement_Plan_Create__c              =  false;
                    opp.Engagement_Plan_Template__c            =  kp.Id;
                    opp.Engagement_Plan__c                     =  kp.Id;
                    opp.CloseDate                              =  Date.today();  
             insert opp;*/
               
        

        
    }

}

 
I have requirement of 1) I have custom button on Order which is accessing method in apex web service class.  This button has to be displayed on custom visual force page depending on below conditions:( if (lookupfield !=null and fulfilmentrelated list is not empty)  in order) display the custom button " Update". 
2) If( lookupfield ==null and fulfilment related list is not empty) display custom button "create".

Can anyone suggest me the approach how to follow?
I have an object "A" . I have custom button ( clone) on Visualforce page vf1. When i click on clone i am able to clone the Object A . Can anyone suggest me best way to achieve this?
We are getting flow error when an integration user runs a script( C sharp code) from his environment, to insert or update data into Salesforce. Can anyone suggest us where would be the error and the resolution Please? It is a high priority task for us now
I have requirement of 1) I have custom button on Order which is accessing method in apex web service class.  This button has to be displayed on custom visual force page depending on below conditions:( if (lookupfield !=null and fulfilmentrelated list is not empty)  in order) display the custom button " Update". 
2) If( lookupfield ==null and fulfilment related list is not empty) display custom button "create".

Can anyone suggest me the approach how to follow?
trigger UpdateOpptyOnServiceupdate on Servic__c (after insert, after update)
{
Set<Id> oppid = new Set<Id>();
Map<Id,List<Service __c>> mpoppservice=new Map<Id,List<Service __c>>();
List<Opportunity> updatelist =  new list<Opportunity>();
String str =  null;
for(Service__c s:trigger.new)
{
if(s.Opportunity__c != null){
oppid.add(s.Opportunity__c);
}
List<Opportunity> opplist = [Select id,ServiceIncrement__c ,(Select id,Expired _Years__c from Service__r) From Opportunity where Id IN:oppid];

For(Opportunity opp:opplist)
{
mpoppservice.put(opp.id,opp. Service__r);   
}
for(Opportunity oppty:opplist)
{
Integer i = 0;   
Id temp = oppty.id;
List<Service __c>  slist= mpoppservice.get(temp);   
if(slist.size()!=0)
{
for(Service__c s1: slist)
{
str =s1. Expired _Years__c;
if(str != '<1' && str != null)   
{
i = 2;
}
if(i==2)   
{
oppty.ServiceIncrement __c = 'Yes';   
}
else
{
oppty.ServiceIncrement __c = 'No';   
}   
updatelist.add(oppty);   
}   
}
}
      try
        {
          update updatelist;
         }catch(Exception e) 
         { 
          for(Service__c s : trigger.new)
          {
          Id opid= s.Opportunity__c;
          Opportunity op = [select id,name from Opportunity where id=:opid];
          s.addError('“Updating opportunity associated to this service,but could not because the required fields are missing on opportunity”');
          }  
       }
 }
}