• Saurabh Sood 12
  • NEWBIE
  • 90 Points
  • Member since 2017

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 21
    Replies
Hi,
I'm writitng test class for this method but unable to get inside  if(pr.size() > 0)  condition.
Can anyone help me out how to resolved it .


public void fetchPriceDetails(){
       
       try
       {
           system.debug('----------------->'+prod);
           for(Product__c p : prod)
           {
               pr = [SELECT List_Price__c FROM Pricing__c WHERE  Location__c =: p.Location__c AND Sub_Product__c =: p.Sub_Product__c AND Product_Detail__c =: p.Product_Details__c  AND  Duration_Type__c  =: p.Select_Duration__c AND Centre__c =: p.Centre__c];
               
             if(pr.size() > 0){

               for(Pricing__c d: pr){
                  if(d.List_Price__c != null || d.List_Price__c != 0)
                       p.List_Price_1__c = pr[0].List_Price__c;
               
               }
               pList.add(p);
               pr.clear();
               system.debug('-------->'+pList);
           }
           
        }
        
        catch(Exception e)
        {
            // ApexPages.addMessages(e);
        }
    }
}

    
Hi everyOne,

I have written first actionfunction code but it not calling to that scipt method as it supose to do so can anyone help me out withthis

This is my controller 
public class wrapperWithRadioButtonCtrl {
    List<Account> acc{get;set;}
    Public Integer records{get;set;}
    public String passedValue{get;set;}
    public wrapperWithRadioButtonCtrl(){
        acc = [select id, name, type from Account limit 10];
        records = acc.size();
        System.debug('Total records are '+ records);
        passedValue ='';
    }
    public List<Account> getaccounts(){
        return acc;
    }
    
    public pageReference dummyCall(){
        System.debug(passedValue);
        return null;
    }
        
}


Visualforce page

<apex:page Controller="wrapperWithRadioButtonCtrl" readOnly="true" >
   <apex:form >
       <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script>
        function MyFunction(){
        alert('hi');
            var i = {!records};
            var selectedRecordIds;
           for(j = 0; j < i; j++){
               console.log('value of j'+ j+'\n');
               if(document.getElementByName("SelectedAccount")[j].checked)
               {
                selectedRecordIds = document.getElementByName("SelectedAccount")[j].value;   
                  console.log('selected Record Id is'+ selectedRecordIds);
               }
           }
            passVariableToController(selectedRecordIds);
    </script>
 
        
    
    <apex:pageBlock >
        <table>
            <Tr><th>Selected Account</th>
            <th>Account Name</th>
            <th>Account Type</th>
           </Tr>
            <apex:repeat value="{!accounts}" var="a" >
            <tr>
                
                <td><input type="radio" value="{!a.id}" name="SelectedAccount"/> </td>
                <td><apex:outputText >{!a.name}</apex:outputText></td>
                <td><apex:outputText >{!a.type}</apex:outputText></td>
                
            </tr>
            </apex:repeat>
        </table>
    </apex:pageBlock>
    <apex:actionFunction name="passVariableToController" action="{!dummyCall}" reRender="pd2">
        <apex:param name="pi" assignTo="{!passedValue}" value="" />
    </apex:actionFunction>
    <apex:commandButton onclick="MyFunction(); return false;" value="Search" />
        <apex:pageBlock id="pb2" title="Account Value">
            <apex:outputText >{!passedValue}</apex:outputText>
       </apex:pageBlock>
     </apex:form>
</apex:page>
Hi everyone,

Created a page with datatable pagination and add checkbox with help of wrapper class the problem is 
When I check some checkbox active and inactive page with help of navigation of datatable and select command button it only send current active page value to controller. 

Controller
public class AccountSearchController1 {
 public Account accNew {
  get;
  set;
 }
 public Account acc {
  get;
  set;
 }
 public boolean isOwner {
  get;
  set;
 }
 public list < wrapAccount > wrapperList {
  get;
  set;
 }
  public list < wrapAccount > selectedRecord {
  get;
  set;
 }
 public List < Account > accList = new List < Account > ();
 
 Map <id,Account> SelectedAccountMap = new Map <id,Account>();
 
 public List < Account > accountList {
  get;
  set;
 }
 public list < Account > changeOwnerList {
  get;
  set;
 }
 public integer LimitSize = 500;
 // create a list of strings to hold the conditions

 List < string > conditions = new List < string > ();

 public AccountSearchController1() {

  system.debug('==>AccountDynamicQuery  is calling==>');
     selectedRecord = new list < wrapAccount > ();
     accNew = new Account();
     acc = new Account();
     accountList = new List < Account > ();
    // cc = new list < wrapAccount > ();
     changeOwnerList = new List < Account > ();
     isOwner = true;

     wrapperList = new List<wrapAccount>();
 }

 public void accSearch() {

  

       accountList.clear();
       conditions.clear();
       SelectedAccountMap.clear();
      wrapperList.clear();
      
       searchAccounts();

  

 }

     public Void searchAccounts() {


          String strQuery = 'SELECT Id,Name,AccountNumber From Account';

      if (acc.Name != null && acc.Name != '') {
            string name = acc.Name + '%' ;
            conditions.add('Name Like : name');
          }

      if (acc.AccountNumber != null && acc.AccountNumber != '') {

       conditions.add('AccountNumber Like\'%' + acc.AccountNumber + '%\' ');

      }

      if (conditions.size() > 0) {

       strQuery += '  WHERE ' + conditions[0];

       for (Integer i = 1; i < conditions.size(); i++)

        strQuery += '  AND ' + conditions[i];

      }

          // add sort and limits at the end

        strQuery += ' ORDER BY Name  ASC LIMIT :LimitSize';

        system.debug('Query string '+ strQuery);
        
        accountList = Database.query(strQuery);

          getSelectedItem();

      

        for (Account a: accountList){

            if(SelectedAccountMap.ContainsKey(a.id))
            {
                wrapperList.add(new wrapAccount(a, true));

            }
            else
            {
                wrapperlist.add(new wrapAccount(a,false));
            }
        }
 

    }
   
    public void getSelectedItem(){

        if(wrapperList != null){


            for(wrapAccount cc: wrapperList){
                
                if (cc.isSelected == true)
                {
                       SelectedAccountMap.put(cc.acc.id,cc.acc);
                }
                else
                {
                    SelectedAccountMap.remove(cc.acc.id);
                }   
            }
                 
        }
    }    

    
 public void changeOwner() {


     getSelectedItem();

     changeOwnerList = SelectedAccountMap.values();
        
 }
 
    

     //wrapper account start
    public class wrapAccount {

        public Account acc {
        get;
        set;
        }

        public boolean isSelected {
        get;
        set;
        }


        public wrapAccount(account a, boolean b) {
        acc = a;
        isSelected = b;

        }
    } //wrapper end 

}

Page 

<apex:page controller="AccountSearchController1" >
    
    <apex:includescript value="//code.jquery.com/jquery-1.11.1.min.js" />
    <apex:includescript value="//cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js" />
    <apex:stylesheet value="//cdn.datatables.net/1.10.4/css/jquery.dataTables.css" />
    
    
    <apex:actionstatus id="counterStatus">
        <apex:facet name="start">
            <div class="waitingSearchDiv" id="el_loading" style="background-color: #fbfbfb; height:100%;opacity:0.65;width:100%;">
                <div class="waitingHolder" style="top: 100px; width: 91px;">
                    <img class="waitingImage" src="/img/loading.gif" title="Please Wait..." />
                    <span class="waitingDescription">Loading...</span>
                </div>
            </div>
        </apex:facet>
    </apex:actionstatus>
  
    
    <apex:form id="theform" >
        <apex:pageBlock >
            <apex:pageBlockSection >
                <apex:inputField value="{!acct.Name}" />
                <apex:inputField value="{!acct.AccountNumber}" />
            </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton action="{!accSearch}" value="search"  status="counterStatus"  />
            </apex:pageBlockButtons>
        </apex:pageBlock>
  
        <apex:pageBlock title="Customers Details" rendered="{!if(wrapperlist != null &&  wrapperlist.size > 0 , true, false)}" >
            
            <apex:pageBlockButtons location="top" >
                <apex:commandButton value="Change Owner" action="{!changeOwner}"  />
            </apex:pageBlockButtons>
            
            <apex:pageBlockTable value="{!wrapperlist}" var="a" id="accTable">
                <apex:column >
                    <apex:inputCheckbox value="{!a.isSelected}">
                        <apex:param assignTo="{!wrapperList}" value="{! a.isSelected}" />
                    </apex:inputCheckbox>
                </apex:column>
                <apex:column value="{!a.acc.Name}"/>
                <apex:column value="{!a.acc.AccountNumber}"/>
             
            </apex:pageBlockTable>
        
        </apex:pageBlock>
        
        <apex:pageblock title="Customer details"  rendered="{!if(changeOwnerList != null && changeOwnerList.size > 0 , true ,false)}" >
         
           <!-- <apex:pageBlockSection columns="1">
               <apex:pageBlockSectionItem >
                  <apex:outputlabel for="owner">New Owner</apex:outputlabel>
                  <apex:inputfield id="owner" value="{!accNew.Name}"/>
               </apex:pageBlockSectionItem>
            </apex:pageBlockSection>-->
            
            <apex:pageBlockSection title="Show Customers" columns="1" collapsible="false" >
               <apex:pageBlockTable value="{!changeOwnerList}" var="o" >
                  <apex:column value="{!o.name}" />
               </apex:pageBlockTable>
            </apex:pageBlockSection>
            
            <apex:pageBlockButtons >
               <apex:commandButton value="Save" action="{!ownerSave}"  reRender="theform"   status="counterStatus" />
                <apex:commandButton value="Cancel" action="{!cancelBack}" immediate="true"  reRender="theform"  status="counterStatus" />
            </apex:pageBlockButtons>
            
         </apex:pageblock>
        
        <script>
            j$ = jQuery.noConflict();
            j$(document).ready( function () {
                var contactTable = j$('[id$="accTable"]').DataTable({
                    stateSave: true
                });
            });
        </script>
    </apex:form>
    
   
</apex:page>
I'm Trying to get Time value from web to lead page but unable to get value it's save with empty field value any one have idea how to get value of time field 
Aura App
<aura:application extends="force:slds">
    <c:myContactCmp recordId='0017F00000S7UjN'/>
</aura:application>

Componet 
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" controller="myContactController" access="global" >
    <aura:handler name="init" action="{!c.getContactList}" value="{!this}" />
    <aura:attribute name="contactList" type="List"/>
</aura:component>

Component controller 
({
    getContactList: function(component, event, handler) {
        
        var action = component.get("c.ContactsList");
        //var accId = component.get("v.recordId");
        alert('acc id '+ component.get("v.recordId"));
        /*action.setParams({
            accId : accId
        });*/
                action.setParams({ AccountId : component.get("v.recordId") });

        action.setCallback(this, function(response){
            var state = response.getState();
            if(state == 'SUCCESS'){
                var contactList = response.getReturnValue();
                //alert("From server: " + contactList);
               //console.log("From server: " + contactList);
               component.set("v.contactList", contactList);
            }else{
                alert('alert in getting data');
            }
        });
            $A.enqueueAction(action);       
    }
})

Apex Controller

It's shows null recordId 

public class myContactController {
    
    @AuraEnabled 
    public static List<Contact> ContactsList(Id accountId){
        system.debug('acc id is '+accountId);
        List<Contact> contacts = [SELECT ID,name,AccountId,Phone,Email from Contact where accountId =: accountId];
        return contacts;
    }
}
 
I have created two objects one is Company and other is an employee. The company has one field that's company name. The employee has three fields emp_name, emp_company and emp_id and the Employee has lookup relationship with the company.

How to assign empId based on Company name 
Suppose company Name is: Delloite then empId should be Del001, the next user will have Del002
If another company is there company name is: Wipro then empId Should be Wip001 and next Wip002

 
 
Hi,
I'm writitng test class for this method but unable to get inside  if(pr.size() > 0)  condition.
Can anyone help me out how to resolved it .


public void fetchPriceDetails(){
       
       try
       {
           system.debug('----------------->'+prod);
           for(Product__c p : prod)
           {
               pr = [SELECT List_Price__c FROM Pricing__c WHERE  Location__c =: p.Location__c AND Sub_Product__c =: p.Sub_Product__c AND Product_Detail__c =: p.Product_Details__c  AND  Duration_Type__c  =: p.Select_Duration__c AND Centre__c =: p.Centre__c];
               
             if(pr.size() > 0){

               for(Pricing__c d: pr){
                  if(d.List_Price__c != null || d.List_Price__c != 0)
                       p.List_Price_1__c = pr[0].List_Price__c;
               
               }
               pList.add(p);
               pr.clear();
               system.debug('-------->'+pList);
           }
           
        }
        
        catch(Exception e)
        {
            // ApexPages.addMessages(e);
        }
    }
}

    
Hi, 
1) I want to duplicate the Locale and Language field of User object to the Quote object.
2) Referring to the figure attached, if I select English (United States) or English (United Kingdom) or English (Vanuatu) from Locale, English should be automatically populated to Language field. How can I do this using apex?

Thanks in advance.
User-added image
Hello All,

I am facing this issue while hitting edit butoon. I am not sure why this error is generating. can someone please look my code and help me to resolve this. Thanks
 
public class AccountSaveCont{

	private ApexPages.StandardController stdCtrl{get;set;}
	public Account acc{get;set;}
	public account accs {get;set;}
	//public string Aid {get;set;}
	public boolean editMode {get;set;}
	public Account accEdit{get;set;}
	//Public Id Id = ApexPages.currentPage().getParameters().get('id');
    public AccountSaveCont(ApexPages.StandardController std) {
		stdCtrl = std;
		acc = (Account) stdCtrl.getRecord();  
		editMode = false;
		if(acc.id != null){
			accs = [select Id,Name,site, type,accountNumber from Account where id=:acc.id]; 		
		} 	
    }

    public pageReference save1(){
      if(acc.site == null){
          acc.site.adderror('Please enter site');
      }else{
         upsert acc;    
           PageReference pg = new PageReference('/' + acc.Id);
            return pg;
      }
      
     return null;
    }
    
    public pageReference edit1(){
        pageReference pgEdit = new pageReference('/'+acc.Id+'/e?retURL=%2Fa'+acc.Id);
		editMode = true;
		if(acc.id != null){
		    accEdit = [select Id,Name,site, type,accountNumber from Account where id=:acc.id];
		} 	
        return null;
    }
    
}

Vf:
<apex:page standardController="Account" extensions="AccountSaveCont" >
    <apex:form >
        <!-- button -->
        <apex:pageBlock mode="maindetail" title="Account Detail">
            <apex:inlineEditSupport showOnEdit="saveButton,cancelButton" hideOnEdit="EditButton" />
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save1}" value="Save" id="saveButton"/>
                <apex:commandButton action="{!edit1}" value="Edit" id="EditButton"/>
                <apex:commandButton action="{!Delete}" value="Delete" id="deleteButton"/>
                <apex:commandButton action="{!cancel}" value="cancel" id="cancelButton"/>               
            </apex:pageBlockButtons>
			<!-- New button -->
            <apex:pageBlockSection title="My Content Section" columns="2" rendered = "{!NOT(editMode)}">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.Account.Fields.name.label}" />
                    <apex:inputField value="{!Acc.name}"/>
                </apex:pageBlockSectionItem>               
                 <apex:pageBlockSectionItem >  
                     <apex:outputLabel value="{!$ObjectType.Account.Fields.Site.label}" />
                    <apex:inputField value="{!Acc.site}"/>
                </apex:pageBlockSectionItem>                    
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$objectType.Account.Fields.Type.label}" />
                    <apex:inputField value="{!Acc.type}"/>
                </apex:pageBlockSectionItem>                  
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$objectType.Account.Fields.website.label}" />
                    <apex:inputField value="{!Acc.accountNumber}"/>
                 </apex:pageBlockSectionItem>                     
            </apex:pageBlockSection>
			
			<!-- Edit Button -->
            <apex:pageBlockSection title="Edit section"   columns="2" rendered = "{!editMode}">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.Account.Fields.name.label}" />
                    <apex:inputField value="{!accEdit.name}"/>
                </apex:pageBlockSectionItem>               
                 <apex:pageBlockSectionItem >  
                     <apex:outputLabel value="{!$ObjectType.Account.Fields.Site.label}" />
                    <apex:inputField value="{!accEdit.site}"/>
                </apex:pageBlockSectionItem>                    
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$objectType.Account.Fields.Type.label}" />
                    <apex:inputField value="{!accEdit.type}"/>
                </apex:pageBlockSectionItem>                  
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$objectType.Account.Fields.website.label}" />
                    <apex:inputField value="{!accEdit.accountNumber}"/>
                 </apex:pageBlockSectionItem>                     
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 
here is my class: 
public class VendorCreationController implements Database.AllowsCallouts, Queueable{
    public String retURL {get; set;}
    public Boolean canProceed {get; set;}
    public String errorMessage {get; set;}
    public Case caseInfo {get; set;}
    public String recordStatus {get; set;}
    
    private String accString;
    private String caseString;

    public VendorCreationController(ApexPages.StandardController controller){
        caseInfo = (Case)controller.getRecord();
    }  

    public PageReference changeStatus() {
        //Check and get case information
        try{
            caseInfo = [SELECT Id, Status, Sub_Status__c, Supplier_Product_Article__c, SAP_Sync_Status__c FROM Case WHERE Id =: caseInfo.Id];
        }catch(Exception e){
            caseInfo = null;
        }
        //check if caseInfo is not null
        if(caseInfo != null){
            try{
                //Case Status
                recordStatus = caseInfo.Status;
                
                //Validate case status/case SAP status
                if (caseInfo.SAP_Sync_Status__c == Label.Sync_in_Progress) {                        
                    canProceed = false;
                    errorMessage = Label.Case_is_already_Sync_in_Progress;
                } 
                else if (caseInfo.Status == Label.In_Review) {                        
                    canProceed = false;
                    errorMessage = Label.Case_is_In_Review;
                } 
                else if (caseInfo.SAP_Sync_Status__c == Label.Sync_Complete) {                        
                    canProceed = false;
                    errorMessage = Label.Case_is_already_Sync_Completed;
                }     
                else {       
                    canProceed = true;
                    caseInfo.SAP_Sync_Status__c = Label.Sync_in_Progress;
                    caseInfo.Status = Label.Sync_with_SAP;
                    update caseInfo;                    
                }   
                
                retURL = '/' + caseInfo.Id;
                PageReference redirectPage = new PageReference(retURL);
                redirectPage.setRedirect(true);
                return redirectPage;
            }catch(Exception e){
                canProceed = false;
                errorMessage = e.getMessage();
                retURL = '/' + caseInfo.Id;
                PageReference redirectPage = new PageReference(retURL);
                redirectPage.setRedirect(true);
                return redirectPage;
            }
            
        }
        return null;
    }
    

    //constructor
    public VendorCreationController(String accStr, String caseStr) {
        this.caseString = caseStr;
        this.accString = accStr;
    }
    

    public void execute(QueueableContext context) {
        Account acc = new Account();
        Case caseRec = new Case();
        Case newCaseRec = new Case();
        Contact conRec = new Contact();
        
        //Custom settings for integration
        Integration_Management__c integrationManagement;
        
        //Check if endpoint url is present
        try{
            integrationManagement = Integration_Management__c.getValues(Label.Vendor_Creation);        
        }catch(Exception e){
            integrationManagement = null;
            //log exception to application log utility
            ApplicationLogUtility.logError('VendorCreationController', 'sendToSAP', e, e.getMessage(), '', 0);
            ApplicationLogUtility.commitLog();
        }
        //Check if endpoint is present in the custom settings
        if(integrationManagement !=null){
            try{
                acc = (Account) JSON.deserialize(accString, Account.Class);
                caseRec = (Case) JSON.deserialize(caseString, Case.Class);
            }catch(Exception e){
                acc = null;
                caseRec = null;
            }
            if(acc != null && caseRec !=null){
                try{
                    newCaseRec = [SELECT Id, ContactId, Status, SAP_Sync_Status__c FROM Case WHERE Id=: caseRec.Id];    
                }catch(Exception e){
                    newCaseRec = null;
                }
                
                if(newCaseRec !=null){
                    try{
                        conRec = [SELECT Id, Phone, HomePhone, OtherPhone, Fax, Email FROM Contact WHERE Id=: newCaseRec.ContactId];            
                    }catch(Exception e){
                        conRec = null;
                    }
                }
                
                try{
                    system.debug('VendorCreationController caseRec: ' + caseRec);            
                    system.debug('VendorCreationController conRec: ' + conRec);
                    system.debug('VendorCreationController sendToSAP enter');
                    sapComDocumentSapRfcFunctionsVendor.Z_VEN_CREATION_BINDING bob = new sapComDocumentSapRfcFunctionsVendor.Z_VEN_CREATION_BINDING();
                    sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_LFA1 IS_LFA1_FIELDS = new sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_LFA1();
                    sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_LFB1 IS_LFB1_FIELDS = new sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_LFB1();
                    sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_LFM1 IS_LFM1_FIELDS = new sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_LFM1();
                    sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_POSTAL_ADD ADDRESS_FLDS = new sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_POSTAL_ADD();
                    sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_COMM COMM_FIELDS = new sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_COMM();
                    
                    sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_PHONE_TT phone = new sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_PHONE_TT();
                    sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_FAX_TT fax = new sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_FAX_TT();
                    sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_EMAIL_TT email = new sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_EMAIL_TT();
                    
                    sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_PHONE contactPhone = new sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_PHONE();
                    sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_FAX contactFax = new sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_FAX();
                    sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_EMAIL contactEmail = new sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_EMAIL();
                    
                    if(conRec !=null){
                        contactPhone.TELEPHONE =checkIfNull(conRec.Phone, 30);
                        contactPhone.COUNTRY = '';
                        contactPhone.EXTENSION = '';
                        if(contactPhone.TELEPHONE!=''){
                            contactPhone.STD_NO = 'X';
                        }
                        
                        contactFax.COUNTRY = '';
                        contactFax.FAX =checkIfNull(conRec.Fax, 30);
                        if(contactFax.FAX!=''){
                            contactFax.STD_NO = 'X';
                        }
                        
                        contactEmail.E_MAIL =checkIfNull(conRec.Email, 241);
                        if(contactEmail.E_MAIL!=''){
                            contactEmail.STD_NO = 'X';
                        }
                        
                        List<sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_PHONE> phoneList = new List<sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_PHONE>(); 
                        phoneList.add(contactPhone);
                        phone.item = phoneList;
                        
                        List<sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_EMAIL> emailList = new List<sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_EMAIL>(); 
                        emailList.add(contactEmail);
                        email.item = emailList;
                        
                        List<sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_FAX> faxList = new List<sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_FAX>(); 
                        faxList.add(contactFax);
                        fax.item = faxList;
                        
                        COMM_FIELDS.PHONE = phone;
                        COMM_FIELDS.FAX = fax;
                        COMM_FIELDS.EMAIL = email;
                        system.debug('VendorCreationController sendToSAP COMM_FIELDS: ' + COMM_FIELDS);
                        
                    }
                    
                    IS_LFA1_FIELDS.STCEG=checkIfNull(acc.ABN__c, 20);
                    
                    IS_LFA1_FIELDS.BEGRU=Label.SMKT; //Need confirmation (defaulted)
                    IS_LFA1_FIELDS.KTOKK=Label.SMKT; //Account Group needs to be added (Questionnaire)   
                    
                    IS_LFA1_FIELDS.STCEG= checkIfNull(acc.ABN__c, 20);
                    IS_LFA1_FIELDS.COMM_FIELDS = COMM_FIELDS;
                    ADDRESS_FLDS.NAME= checkIfNull(acc.TradingName__c, 40);
                    ADDRESS_FLDS.CITY=checkIfNull(acc.BillingCity, 40);
                    ADDRESS_FLDS.POSTL_COD1=checkIfNull(acc.BillingPostalCode, 10);
                    ADDRESS_FLDS.STREET=checkIfNull(acc.BillingStreet, 60);
                    //ADDRESS_FLDS.STR_SUPPL1='STREET2'; //Mat to Comeback
                    ADDRESS_FLDS.COUNTRY=checkIfNull(acc.Country__c, 3);
                    ADDRESS_FLDS.LANGU=Label.English; //Constant
                    ADDRESS_FLDS.REGION=checkIfNull(acc.BillingState, 3);
                    ADDRESS_FLDS.SORT1=Label.Tilde_Sign; //Tilde Sign
                    String referenceVendor = '';
                    if(acc.Trading_Term__c != null){
                        system.debug('Trading Term Not Null');	                   
                        Trading_Terms__c tradingTerm = [SELECT Id, Reference_Vendor__c, PaymentMethod__c, PaymentTermsCode__c FROM Trading_Terms__c WHERE Id=: acc.Trading_Term__c];
                        referenceVendor = tradingTerm.Reference_Vendor__c;
                        IS_LFB1_FIELDS.UZAWE = tradingTerm.PaymentMethod__c;
                        IS_LFB1_FIELDS.ZTERM = tradingTerm.PaymentTermsCode__c;
                        referenceVendor = tradingTerm.Reference_Vendor__c;
                        system.debug('Vendor referenceVendor ' + referenceVendor);
                    }
                    
                    ADDRESS_FLDS.SORT2='';
                    IS_LFA1_FIELDS.ADDRESS_FIELDS=ADDRESS_FLDS;
                    
                    //Australia
                    if(acc.Country__c == Label.AU){
                        IS_LFB1_FIELDS.BUKRS=Label.AU_Company_Code;
                    }
                    //New Zealand
                    else if(acc.Country__c == Label.NZ){
                        IS_LFB1_FIELDS.BUKRS= Label.NZ_Company_Code; 
                    }
                    
                    IS_LFM1_FIELDS.EKORG=Label.X1000; 
                    bob.timeout_x = Integer.valueOf(Label.Timeout);
                    String IV_USER_ID = '';
                    try{
                        User curUser = [SELECT Id, ActiveDirectoryId__c FROM User WHERE Id =: UserInfo.getUserId() LIMIT 1];
                        IV_USER_ID = curUser.ActiveDirectoryId__c;                
                    }catch(Exception e){
                        IV_USER_ID = '';
                    }
                    system.debug('VendorCreationController sendToSAP IV_USER_ID: ' + IV_USER_ID);
                    
                    sapComDocumentSapRfcFunctionsVendor.BAPIRET2_T response = new sapComDocumentSapRfcFunctionsVendor.BAPIRET2_T();
                    response = bob.Z_VEN_CREATION(IS_LFA1_FIELDS, IS_LFB1_FIELDS,IS_LFM1_FIELDS,Label.Default_Logic_Key,referenceVendor,IV_USER_ID);
                    //String IV_REF_VENDOR
                    
                    parseResponse(response, acc, caseRec);
                }catch(Exception e){
                    Web_Service_Log__c logs = new Web_Service_Log__c();
                    //Custom Settings
                    logs.Endpoint__c =  integrationManagement.SAP_Endpoint__c;
                    logs.Error_Message__c= Label.ERROR;
                    logs.Error_Message__c += e;
                    logs.Log_Type__c= Label.Case_Vendor_Create_Error;
                    logs.Service_Name__c = Label.Vendor_Webservice_Error;
                    logs.Status_Code__c = CaseRec.id;
                    insert logs;
                    
                    caseRec.Integration_Error_Message__c = e.getMessage();
                    caseRec.SAP_Sync_Status__c = Label.Sync_Error;
                    caseRec.Status = Label.Approved;
                    update caseRec;
                }
            }
        }        
    }
    

    public static String checkIfNull(String str, Integer maxSize){
        if(str == null){
            str = '';
        }
        else{
            if(str.length() > maxSize ){
                str = str.substring(0, maxSize);
            }
        }
        return str;
    }

    public static void parseResponse(sapComDocumentSapRfcFunctionsVendor.BAPIRET2_T response, Account acc, Case caseRec){
        //Get Integration Management Custom Settings
        Integration_Management__c integrationManagement;        
        try{
            //Get Endpoint URL
            integrationManagement = Integration_Management__c.getValues(Label.Vendor_Creation);        
        }catch(Exception e){
            //log exception to application log utility
            ApplicationLogUtility.logError('VendorCreationController', 'parseResponse', e, e.getMessage(), '', 0);
            ApplicationLogUtility.commitLog();
            integrationManagement = null;
        }
        
        //Check if custom settings not null
        if(integrationManagement !=null){
            if(response !=null){
                if(response.item !=null){
                    system.debug('VendorCreationController parseResponse response: ' + response);
                    system.debug('VendorCreationController parseResponse response: ' + response.item);
                    String message = '';
                    Boolean hasError = false;
                    for (sapComDocumentSapRfcFunctionsVendor.BAPIRET2 item : response.item){
                        system.debug('VendorCreationController parseResponse item: ' + item);
                        system.debug('VendorCreationController parseResponse MESSAGE: ' + item.MESSAGE);
                        system.debug('VendorCreationController parseResponse TYPE_X: ' + item.TYPE_x);
                        if(item.TYPE_x == 'E'){
                            hasError = true;
                        }
                        
                        if(item.MESSAGE!=null){
                            message = item.MESSAGE;                    
                        }
                    }
                    
                    if(!hasError){
                        String vendorNumber = message.replace('Vendor Number created ', '');
                        vendorNumber = vendorNumber.replace('.','');
                        //Update Legacy Vendor Number
                        //Update to Sync Completed
                        //Update Account Vendor Number
                        system.debug('VendorCreationController parseResponse vendorNumber: ' + vendorNumber);
                        acc.VendorNumber__c = vendorNumber;
                        update acc;
                        
                        //Case Record Update
                        caseRec.Integration_Error_Message__c = Label.Vendor_Successful;
                        caseRec.SAP_Sync_Status__c = Label.Sync_Complete;
                        caseRec.Status = 'Sync With SAP Completed';
                        update caseRec;
                        //Lock case
                        Approval.UnlockResult unlockCase = Approval.unlock(caseRec, false);
                        if (unlockCase.isSuccess()) {
                            //Operation was successful, so get the ID of the record that was processed
                            System.debug('Successfully unlocked case with ID: ' + unlockCase.getId());
                        }
                        else {
                            //Operation failed, so get all errors                
                            for(Database.Error err : unlockCase.getErrors()) {
                                System.debug('The following error has occurred.');                    
                                System.debug(err.getStatusCode() + ': ' + err.getMessage());
                                System.debug('Case fields that affected this error: ' + err.getFields());
                            }
                        }
                        
                        //Update Web Service Logs
                        Web_Service_Log__c logs = new Web_Service_Log__c();
                        //Custom Settings
                        logs.Endpoint__c =  integrationManagement.SAP_Endpoint__c;
                        logs.Error_Message__c = message;
                        logs.Log_Type__c= Label.Case_Vendor_Create_Successful;
                        logs.Service_Name__c = Label.Vendor_Webservice_Success;
                        logs.Status_Code__c = CaseRec.id;
                        insert logs;
                        
                        system.debug('VendorCreationController parseResponse Account Vendor Number Updated');
                    }
                    else{
                        //Update Web Service Logs
                        Web_Service_Log__c logs = new Web_Service_Log__c();
                        //Custom Settings
                        logs.Endpoint__c =  integrationManagement.SAP_Endpoint__c;
                        logs.Error_Message__c= Label.ERROR;
                        logs.Error_Message__c += message;
                        logs.Log_Type__c= Label.Case_Vendor_Create_Error;
                        logs.Service_Name__c = Label.Vendor_Webservice_Error;
                        logs.Status_Code__c = CaseRec.id;
                        insert logs;
                        
                        //Update case
                        caseRec.Integration_Error_Message__c = message;
                        caseRec.SAP_Sync_Status__c = Label.Sync_Error;
                        caseRec.Status = Label.Approved;
                        update caseRec;
                    }
                }
                else{
                    //No Response
                    caseRec.Integration_Error_Message__c = Label.No_Response_Received_From_The_Webservice;
                    caseRec.SAP_Sync_Status__c = Label.Sync_Error;
                    caseRec.Status = Label.Approved;
                    update caseRec;
                }
            }
            else{
                //No Response
                caseRec.Integration_Error_Message__c = Label.No_Response_Received_From_The_Webservice;
                caseRec.SAP_Sync_Status__c = Label.Sync_Error;
                caseRec.Status = Label.Approved;
                update caseRec;
            }
        }
    }
}

please help me out thank you :) 
Hello guys,

I need to write a SOQL with sorting on 2 columns , start date and created date, can it possible to sort on multiple columns , or by default Apex considers only the first column used in sorting , please help
Thanks !
Hi,

I have a situation here. I have created a trigger to update the field value present in the parent object whenever a child object gets created or updated. The trigger is created on parent object. I have pushed the code in the production, but the problem is unless parent or the child object gets refreshed or updated, the trigger is not getting hit. This results in stale value in the filed that was supposed to be updated. 

Is there any easy way that I can refresh all the production data so that the trigger gets hit and update the field value.?
Since this is a priority issue, any help would be highly appreciated.

Thanks,
Hello,

I have a user with a profile.
I want to make changes in FLS only for this user.

how can i implement it ?
Hi experts,
 I am unable to see any element in Palette, Resources or explorer.
You can see as below screenshots

User-added imageUser-added imageUser-added image

Any help will be appreciated.
I need to apply pagination on nearly 400k records in a VF page. Is there a way to do that?
I have created two objects one is Company and other is an employee. The company has one field that's company name. The employee has three fields emp_name, emp_company and emp_id and the Employee has lookup relationship with the company.

How to assign empId based on Company name 
Suppose company Name is: Delloite then empId should be Del001, the next user will have Del002
If another company is there company name is: Wipro then empId Should be Wip001 and next Wip002

 
 
Hi friends
i want a trigger code for this
When a contact is made primary(1) the city of the contact should be updated in the Account’s city(3) field. User-added image