• Shubhangi Jadhav
  • NEWBIE
  • 20 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 9
    Replies
global class GetPickValuesExitWH implements vlocity_cmt.VlocityOpenInterface2 {
 Object wareHouseName ='';
 Object wareHouseIdTask=''; 
    
global Object invokeMethod(String methodName, Map < String, Object > inputMap, Map < String, Object > outMap,Map < String, Object > options)
{
       
if (String.isNotBlank(methodName) && methodName.equalsIgnoreCase('GetPicklistValueExitWH'))
{
set<String> pickListValuesList= new set<String>();
Schema.DescribeFieldResult fieldResult = Order.Tet_Exit_Warehouse__c.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
for( Schema.PicklistEntry pickListVal : ple)
{
pickListValuesList.add(pickListVal.getLabel());    
}
    outmap.put('PicklistValues',pickListValuesList);
    return pickListValuesList;
   
   
}

if (String.isNotBlank(methodName) && methodName.equalsIgnoreCase('GetPicklistValueForPacking'))
{   String wareHouseId = (string)inputMap.get('WareHouseId');
    String wareHouseNameTask = (string)inputMap.get('WareHouseName');
    
    List<Map<String,String>> values = new List<Map<String,String>>();
    for(Schema.PicklistEntry e : Order.Tet_Exit_Warehouse__c.getDescribe().getPicklistValues()) {
           String value = e.getValue();
           String label = e.getLabel();
           if(value == wareHouseId )
           {
            wareHouseName = (Object)label ;
            break;
           }
        if(label== wareHouseNameTask)
        {
            wareHouseIdTask=(Object)value;
            break;
        }
        }
 
   outMap.put('wareHouseName', wareHouseName);
   outMap.put('wareHouseId', wareHouseIdTask);
    }

    return null;
}
}
Old:Status <> new:status and Old:Status = Cancelled then stop saving of record

I need to compare value and need to stop by saving the record
if order status is cancelled it should not be editable by user
                String prdName=(String)prodByNumbe.get('Name');
                String prdSrlNum=(String)prodByNumbe.get('value');
                String orderItemQuer;
                 system.debug('OrderItem' +orderItemQuer);
                 if(listOrderItem.size()==0)
                  {orderItemQuer='SELECT Id FROM OrderItem WHERE OrderId='+'\''+inputMap.get('ContextId')+'\''+' AND Product2.Name='+'\''+prdName+'\'';}
                 else{orderItemQuer='SELECT Id FROM OrderItem WHERE OrderId='+'\''+inputMap.get('ContextId')+'\''+' AND Product2.Name='+'\''+prdName+'\''+' AND Id !='+'\''+listOrderItems[0].Id+'\'';}
                  listOrderItems.clear();
                  listOrderItems=Database.query(orderItemQuer);
                  listOrderItem.add(new OrderItem(Id=listOrderItems[0].Id,OrderId=(String)inputMap.get('ContextId'),Tet_Serial_Number__c=prdSrlNum));
                 }update listOrderItem;}
I wrote below code on Product object to test:
I want 
"Days parameter should be configurable"
How can i use label for days

global class TetCleanupBacth_Product implements Database.Batchable<sObject>,Schedulable{
    static Date today1 = Date.today().addDays(-1);

    public Database.QueryLocator start(Database.BatchableContext context)
    {
        return Database.getQueryLocator('Select ID from Tet_LoadProduct__c where LastModifiedDate < :today1' AND status__c in ('Success','Processed'));
    }

    global void execute(Database.BatchableContext context, List<SObject> records)
    {
        delete records;
    }

    global void execute(SchedulableContext ctx) 
    {
        Database.executeBatch(new TetCleanupBacth_Product());
    }
    
     global void finish(Database.BatchableContext BC) {
           
      }
}

But getting error while saving.
Please help me to get this lines coverd in my test class:



       try{
           if(errorFlagfromIP != null && errorFlagfromIP instanceOf Boolean)
             {
               Boolean failFlag =(Boolean)errorFlagfromIP;
               
               if(failFlag==true) // Error Code Received from the Interface (SOA ERROR)
                        {
                        
                         Boolean errorFromInterface=true;  
                                              
                       if(errorFromInterface)
                       
                               {
                               System.debug('Callout has error from interface : ' + errorFromInterface);
                               }              
                       
                                                }
                        if(failFlag==false) 
                         {
                         
                         throw new vlocity_cmt.XOMOrchestrationInterfaces.SystemInterfaceRecoverableException('No Response Returned From HTTP Action or Interface');
                         
                         }
 

           }
       }Catch(CalloutException e)
           {
            throw new vlocity_cmt.XOMOrchestrationInterfaces.SystemInterfaceRecoverableException ('Callout exception ' + e + ': trying to retry');    
           }
Hi ,

Can anyone help me to get this code.

Regards,
Shubhangi
Please find attchment for your reference.

Regards,
ShubhangiUser-added image
Hi,

Anyone can help me to write trigger on order.
other than admin no one should be able to "delete" order.
Thank you.

Regards,
Shubhangi
for(vlocity_cmt__OrchestrationItem__c items:Trigger.New)
         {            
            if(items.Name=='Generate Bill Manual Task')
                {
                allItemsGenBilling.add(items);
                }
         }
        
           if(allItemsGenBilling.size()>0)
                {
                Tet_GenerateBillManualTaskForGenBill.UpdateOrderStatus(allItemsGenBilling);  
                }
Can anyone tell me how to cover these two lines in test class:

for(id conId:mapContactPrimary.keyset())                 {                     mapContactPrimary.get(conid).addError(System.Label.Tet_UniquePID);                   }
Code is:

@isTest   
    public static void testMethod4(){
   
        Account acc1 =new Account();
        acc1.Name='Managal';
        insert acc1;
        
        Account acc2 =new Account();
        acc2.Name='Managala';
        insert acc2;
        
        contact con=new contact();
        con.lastname='Jyoti';
        con.firstname='Savalgi';
        con.AccountId=acc1.id;
        con.Tet_Contact_Pid__c = '060587-12949';
        insert con;
        
        AccountContactRelation Acctcr=
        new  AccountContactRelation(AccountId=acc2.id,ContactId=con.id,Tet_IsPrimaryContact__c= True);
                                
        insert Acctcr;
        
        Acctcr.Tet_IsPrimaryContact__c= True;
        update con;//Updated Primary to contact Sam
        
        Account acc3 =new Account();
        acc3.Name='Bibhu';
        insert acc3;
        
        Account acc4 =new Account();
        acc4.Name='Bibhudutta';
        insert acc4;
        
        contact con1=new contact();
        con1.lastname='Ankit';
        con1.firstname='Savalgi';
        con1.AccountId=acc3.id;
        con1.Tet_Contact_Pid__c = '200568-13106';
        insert con;
        
        AccountContactRelation Acctcr1=
        new  AccountContactRelation(AccountId=acc4.id,ContactId=con.id,Tet_IsPrimaryContact__c= True);
        insert Acctcr1;
        
        Acctcr1.Tet_IsPrimaryContact__c= True;
        update con1;//Updated Primary to contact Ankit
        
        con.Tet_Contact_Pid__c=con1.Tet_Contact_Pid__c;
        update con;
        system.debug('Value of 2nd contact is:' +con1.Tet_Contact_Pid__c);
        
    }
Old:Status <> new:status and Old:Status = Cancelled then stop saving of record

I need to compare value and need to stop by saving the record
I wrote below code on Product object to test:
I want 
"Days parameter should be configurable"
How can i use label for days

global class TetCleanupBacth_Product implements Database.Batchable<sObject>,Schedulable{
    static Date today1 = Date.today().addDays(-1);

    public Database.QueryLocator start(Database.BatchableContext context)
    {
        return Database.getQueryLocator('Select ID from Tet_LoadProduct__c where LastModifiedDate < :today1' AND status__c in ('Success','Processed'));
    }

    global void execute(Database.BatchableContext context, List<SObject> records)
    {
        delete records;
    }

    global void execute(SchedulableContext ctx) 
    {
        Database.executeBatch(new TetCleanupBacth_Product());
    }
    
     global void finish(Database.BatchableContext BC) {
           
      }
}

But getting error while saving.
for(vlocity_cmt__OrchestrationItem__c items:Trigger.New)
         {            
            if(items.Name=='Generate Bill Manual Task')
                {
                allItemsGenBilling.add(items);
                }
         }
        
           if(allItemsGenBilling.size()>0)
                {
                Tet_GenerateBillManualTaskForGenBill.UpdateOrderStatus(allItemsGenBilling);  
                }
Code is:

@isTest   
    public static void testMethod4(){
   
        Account acc1 =new Account();
        acc1.Name='Managal';
        insert acc1;
        
        Account acc2 =new Account();
        acc2.Name='Managala';
        insert acc2;
        
        contact con=new contact();
        con.lastname='Jyoti';
        con.firstname='Savalgi';
        con.AccountId=acc1.id;
        con.Tet_Contact_Pid__c = '060587-12949';
        insert con;
        
        AccountContactRelation Acctcr=
        new  AccountContactRelation(AccountId=acc2.id,ContactId=con.id,Tet_IsPrimaryContact__c= True);
                                
        insert Acctcr;
        
        Acctcr.Tet_IsPrimaryContact__c= True;
        update con;//Updated Primary to contact Sam
        
        Account acc3 =new Account();
        acc3.Name='Bibhu';
        insert acc3;
        
        Account acc4 =new Account();
        acc4.Name='Bibhudutta';
        insert acc4;
        
        contact con1=new contact();
        con1.lastname='Ankit';
        con1.firstname='Savalgi';
        con1.AccountId=acc3.id;
        con1.Tet_Contact_Pid__c = '200568-13106';
        insert con;
        
        AccountContactRelation Acctcr1=
        new  AccountContactRelation(AccountId=acc4.id,ContactId=con.id,Tet_IsPrimaryContact__c= True);
        insert Acctcr1;
        
        Acctcr1.Tet_IsPrimaryContact__c= True;
        update con1;//Updated Primary to contact Ankit
        
        con.Tet_Contact_Pid__c=con1.Tet_Contact_Pid__c;
        update con;
        system.debug('Value of 2nd contact is:' +con1.Tet_Contact_Pid__c);
        
    }