• harshita gupta 33
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
this is my apex code:
public class test1CLASS {
    
    public List<SelectOption> CustomerList {get;set;}
    public List<SelectOption> MasterMaterialList {get;set;}
    public List<SelectOption> RetailerList {get;set;}
    public List<SelectOption> influencerList {get;set;}
    public List<SelectOption> shipList {get;set;}
    public List<SelectOption> plantList {get;set;}
    
     public boolean dispSectBool{get;set;}
    public Sale_Order__c saleobj;
     public string pcode;
    public string mcode;
    public string cuscode;
    public string unload;
    public string iduser;
    public List<string> ratevf;
     public ApexPages.StandardController ctrl;
    
    public test1CLASS(ApexPages.StandardController controller)
    { 
        saleobj=(Sale_Order__c)controller.getRecord();
        dispSectBool = false;
     
        CustomerList = new List<SelectOption>();
        MasterMaterialList = new List<SelectOption>();
        RetailerList = new List<SelectOption>();
        influencerList = new List<SelectOption>();
        shipList = new List<SelectOption>();
        plantList = new List<SelectOption>();
        
         CustomerList.add(new SelectOption('','--None--'));
        MasterMaterialList.add(new SelectOption('','--None--'));
        RetailerList.add(new SelectOption('','--None--'));
        influencerList.add(new SelectOption('','--None--'));
        shipList.add(new SelectOption('','--None--'));
        plantList.add(new SelectOption('','--None--'));
        
       Iduser=userinfo.getUserId();
        List<Account> CustomerData = [Select Id,Name from Account];
         
         for(Account cl: CustomerData){
         
            CustomerList.add(new SelectOption(cl.Id,cl.Name));
       }
        
        List<Account> RetailerData = [Select Id,Name,AccountType__c from Account where AccountType__c='Retailer'];
         for(Account cl: RetailerData){
            RetailerList.add(new SelectOption(cl.Id,cl.Name));
        }
        
        List<contact> influencerData = [Select Id,Name,Type__c from contact where Type__c='Influencer'];
         for(contact cl: influencerData){
            influencerList.add(new SelectOption(cl.Id,cl.Name));
        }
        
        List<Ship_to_Party__c> shipData = [Select Id,Name__c from Ship_to_Party__c];
         for(Ship_to_Party__c cl: shipData){
            shipList.add(new SelectOption(cl.Id,cl.Name__c));
        }
        
        List<plants__c> plantData = [Select Id,Name from plants__c];
         for(plants__c cl: plantData){
            plantList.add(new SelectOption(cl.Id,cl.Name));
        }
        if(saleobj.Id != null){
                getMaster();
            }
    }
public void getbag()
{
    saleobj.Quantity_in_MT__c=(saleobj.Quantity_in_Bag__c)/20;
}
    public void getMaster(){
        MasterMaterialList.clear();
        MasterMaterialList.add(new SelectOption('','--None--'));
        Account acc=[Select id,Customer_material_code__c from Account Where id=:saleobj.Customer__c Limit 1];
        if(acc.Customer_material_code__c!=null){
            //List<Customer_Group_Material__c > master=[select id,name,Material_Name__c from Customer_Group_Material__c where Name=:acc.customer_material_code__c];
           List<Customer_Group_Material__c> master=[select id,name,MaterialName__c from Customer_Group_Material__c where Name=:acc.Customer_material_code__c];
            for(Customer_Group_Material__c pl: master){
                system.debug('123');
                system.debug(pl.id);
             MasterMaterialList.add(new SelectOption(pl.Id,pl.MaterialName__c));
            //MasterMaterialList.add(new SelectOption(pl.Id,pl.Name));
            //List<MasterDatabase__c > master=[select id,name,Material_Group__c from MasterDatabase__c where Material_Group__c=:acc.customer_material_code__c AND RecordTypeId='0121m0000006olYAAQ'];
            // for(MasterDatabase__c pl: master){
            // MasterMaterialList.add(new SelectOption(pl.Id,pl.Name));
        }
        }
    }
    
public void getcredit()
{
    cuscode=saleobj.Customer__c;
    system.debug(cuscode);
    
}
public void getvalue()
{
   pcode=saleobj.Plant_Code1__c;//plantcode
   mcode=saleobj.accountcustomer_code__c;//materialcode
    if(saleobj.Customer__c!=null && saleobj.Ship_To_Party1__c==null && saleobj.Transportation_Zone__c==null )
    {
        string custmcode=saleobj.Customer__c;
        unload =[Select id,Name, UnloadingPointId__r.Name FROM Account where id=:custmcode limit 1].UnloadingPointId__r.Name;
        //unload =[Select id,Name, UnloadingPointId__c FROM Account where id=:custmcode limit 1].UnloadingPointId__c;
       saleobj.Unloading_Point_Receiving_Point__c= unload;
        
    }    
    else if(saleobj.Customer__c!=null && saleobj.Ship_To_Party1__c!=null && saleobj.Transportation_Zone__c==null)
    {
        
         system.debug(saleobj.Ship_To_Party1__c);
            string salecode=saleobj.Ship_To_Party1__c;
            unload =[Select id,Unloading_point__c FROM Ship_To_Party__c where id=:salecode limit 1].Unloading_point__c;
       saleobj.Unloading_Point_Receiving_Point__c=unload;
        
        }
        else if(saleobj.Customer__c!=null && saleobj.Ship_To_Party1__c==null && saleobj.Transportation_Zone__c!=null)
        {
            unload =[Select id,Name FROM MasterDatabase__c where id=:saleobj.Transportation_Zone__c limit 1].Name;
            saleobj.vfpageONE_TIME_unloading_point__c=unload;
            saleobj.Unloading_Point_Receiving_Point__c=unload;
           
        }
   ratevf=RATECGP1SAP.call('a141m0000004TXbAAM');
    String FRate1=ratevf.get(0);
    String Rate1=ratevf.get(1);
    String gp1=ratevf.get(2);
    String gp2=ratevf.get(3);
    system.debug('test'+FRate1);
     system.debug('test'+Rate1);
    system.debug('testgp1'+gp1);
     
    saleobj.Freight_Amount__c=decimal.valueOf(FRate1);
    saleobj.Rate__c=decimal.valueOf(Rate1);
    saleobj.Group_1__c=gp1;
    saleobj.Group_2__c=gp2;
     system.debug(''+pcode);//plantcode
    system.debug(mcode);//materialcode
    system.debug(unload);//unloading point
   
}
  
    
    public pagereference dispSect()
    {
        dispSectBool = true;
        system.debug('asdfasdfasdf');
        return null;
    }
    
     public PageReference save() {
        try {
            insert(saleobj);
        } catch(System.DMLException e) {
            ApexPages.addMessages(e);
            return null;
        }
        //  After successful Save, navigate to the default view page
          PageReference pageRef = new PageReference('');

   pageRef.setRedirect(true);

   return pageRef;

        
    }
     public PageReference cancel() {
                 
        //  After unsuccessful , navigate to the record view page
          PageReference pageRef = new PageReference('');

   pageRef.setRedirect(true);

   return pageRef;

        
    }
}
regards
harshita 
 
HI, when i am previewing my lightning component the page become unresponsive.Actually my apex class return --Vehicle Arranged,,,1110000077,Vehicle Arranged,,        1,1110000077--
and i want to add the value at position 1,5 and the added value to the lightning component:(
This is my apex class returning the string:
public class ordercall {
        public static List<String> t =new List<String>() ;
    public static String[] tmp1 = New String[]{};
        public static String idString;
  @AuraEnabled 
    public static String call(){
        
        orderStatuswsdl.MI_Order_Status_sfdcPort Mobile= new orderStatuswsdl.MI_Order_Status_sfdcPort();
       String Username='dlskv';
        String Password='sapabap1';
        Blob auth = Blob.valueOf(Username+':'+Password);
        String AuthorizationHeader ='Basic '+EncodingUtil.Base64Encode(auth);
        Mobile.inputHttpHeaders_x= new Map<String,String>();
        Mobile.inputHttpHeaders_x.put('Authorization', AuthorizationHeader );
        Mobile.inputHttpHeaders_x.put('Content-Type', 'text/xml;charset=UTF-8;');
        Mobile.timeout_x=119999;
          orderStatuswsdl.ROW_element element= new orderStatuswsdl.ROW_element();
        
        
           element.CUSTOMER='1110000077';
          element.SALES_ORDER='';
        
         element.Sales_Org='1000';
     //   element.SALES_OFFICE='1702';
        
         orderStatuswsdl.ROW_element[] req= new orderStatuswsdl.ROW_element[]{element};
             system.debug(req);
             
             
             
             orderStatuswsdl.ROW_element[] res = new orderStatuswsdl.ROW_element[]{};
           res= Mobile.MI_Order_Status_sfdc(req);
        for(orderStatuswsdl.ROW_element reqq: res){
          system.debug(reqq.LR);
             tmp1.add(reqq.LR);
             tmp1.add(reqq.QUANTITY );
            tmp1.add(reqq.SALES_ORDER);
               tmp1.add(reqq.CUSTOMER);
            
        }
       
        idString = string.join(tmp1,',');
       system.debug(idString);
        return idString;
    }
      
    }
my js controller code:

 mycomp : function(component, event, helper) {
        var action=component.get("c.call");
        action.setCallback(this, function(response){
            var state=response.getState(); 
            if(state === "SUCCESS"){
                 var qm=response.getReturnValue();
                 var arr = qm.split(',');
                var penquantity;
                var quantity;
               var size=arr.length;
                 
              for(var i=0;i<size+1;i+4)
                {
                     if(arr[i]==="Vehicle Arranged" || arr[i]==="Vehicle Entered Plant" || arr[i]==="Order Processed Date & Time")
                    {
                           var penquantity=arr[i+2];
                   } 
               else
                {
                   if(arr[i]==="Dispatched")
                   {
                      quantity=arr[i+1];
                   }
                }
                }
            var underprg = component.get("v.underprg");       
                component.set("v.underprg",penquantity); 
            }
            });
        $A.enqueueAction(action);
        
    }
HI, when i am previewing my lightning component the page become unresponsive.Actually my apex class return --Vehicle Arranged,,,1110000077,Vehicle Arranged,,        1,1110000077--
and i want to add the value at position 1,5 and the added value to the lightning component:(
This is my apex class returning the string:
public class ordercall {
        public static List<String> t =new List<String>() ;
    public static String[] tmp1 = New String[]{};
        public static String idString;
  @AuraEnabled 
    public static String call(){
        
        orderStatuswsdl.MI_Order_Status_sfdcPort Mobile= new orderStatuswsdl.MI_Order_Status_sfdcPort();
       String Username='dlskv';
        String Password='sapabap1';
        Blob auth = Blob.valueOf(Username+':'+Password);
        String AuthorizationHeader ='Basic '+EncodingUtil.Base64Encode(auth);
        Mobile.inputHttpHeaders_x= new Map<String,String>();
        Mobile.inputHttpHeaders_x.put('Authorization', AuthorizationHeader );
        Mobile.inputHttpHeaders_x.put('Content-Type', 'text/xml;charset=UTF-8;');
        Mobile.timeout_x=119999;
          orderStatuswsdl.ROW_element element= new orderStatuswsdl.ROW_element();
        
        
           element.CUSTOMER='1110000077';
          element.SALES_ORDER='';
        
         element.Sales_Org='1000';
     //   element.SALES_OFFICE='1702';
        
         orderStatuswsdl.ROW_element[] req= new orderStatuswsdl.ROW_element[]{element};
             system.debug(req);
             
             
             
             orderStatuswsdl.ROW_element[] res = new orderStatuswsdl.ROW_element[]{};
           res= Mobile.MI_Order_Status_sfdc(req);
        for(orderStatuswsdl.ROW_element reqq: res){
          system.debug(reqq.LR);
             tmp1.add(reqq.LR);
             tmp1.add(reqq.QUANTITY );
            tmp1.add(reqq.SALES_ORDER);
               tmp1.add(reqq.CUSTOMER);
            
        }
       
        idString = string.join(tmp1,',');
       system.debug(idString);
        return idString;
    }
      
    }
my js controller code:

 mycomp : function(component, event, helper) {
        var action=component.get("c.call");
        action.setCallback(this, function(response){
            var state=response.getState(); 
            if(state === "SUCCESS"){
                 var qm=response.getReturnValue();
                 var arr = qm.split(',');
                var penquantity;
                var quantity;
               var size=arr.length;
                 
              for(var i=0;i<size+1;i+4)
                {
                     if(arr[i]==="Vehicle Arranged" || arr[i]==="Vehicle Entered Plant" || arr[i]==="Order Processed Date & Time")
                    {
                           var penquantity=arr[i+2];
                   } 
               else
                {
                   if(arr[i]==="Dispatched")
                   {
                      quantity=arr[i+1];
                   }
                }
                }
            var underprg = component.get("v.underprg");       
                component.set("v.underprg",penquantity); 
            }
            });
        $A.enqueueAction(action);
        
    }