• sfdc D
  • NEWBIE
  • 5 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Lets say , we have custom settings and administrator will place class name in custom settings and from apex code I will get that class name  and i can store it to string but there are some methods in that class (Methods will be static ) suppose there is a method called SumValues and I want to call method or pass some parameters. i was able to call controller with below code and dont have an idea , how to call method ?

string str = 'myEmailClass';
Type t = Type.forName(str);
Object s2 = (Object)t.newInstance();


 
User-added image
Apex Code used to create SIN:

 c2g__codaInvoice__c objNewSIN = new c2g__codaInvoice__c();
                  objNewSIN.c2g__Account__c = so.Bill_To__c;
                  objNewSIN.Prepayment_SIN__c = true;
                  objNewSIN.c2g__OwnerCompany__c = so.Company__c;
                  objNewSIN.Company1__c = so.Company__c;
                  system.debug('==Currencty Code==='+so.Currency_Code__c);
                  system.debug('==Currencty Code==='+so.Company__c);
                  system.debug('==mapCurrency==='+mapCurrency);
                  if(so.CurrencyIsoCode != 'RMB'){ 
                      if(so.CurrencyIsoCode != null && mapCurrency != null && mapCurrency.get(so.CurrencyIsoCode+'-'+so.Company__c) != null){
                          objNewSIN.Accounting_Currency__c = mapCurrency.get(so.CurrencyIsoCode+'-'+so.Company__c).id;
                          objNewSIN.c2g__InvoiceCurrency__c =  mapCurrency.get(so.CurrencyIsoCode+'-'+so.Company__c).id;
                      }                       
                  }else if(so.CurrencyIsoCode == 'RMB'){
                      if(so.CurrencyIsoCode != null && mapCurrency != null && mapCurrency.get('CNY'+'-'+so.Company__c) != null){
                          objNewSIN.Accounting_Currency__c = mapCurrency.get('CNY'+'-'+so.Company__c).id;
                          objNewSIN.c2g__InvoiceCurrency__c =  mapCurrency.get('CNY'+'-'+so.Company__c).id;
                      }
                  }
                  system.debug('====='+objNewSIN.c2g__InvoiceCurrency__c);
                  objNewSIN.Sales_Order__c = so.Id; 
                  objNewSIN.Sales_Order_1__c = so.SO_number__c;
                  objNewSIN.c2g__InvoiceStatus__c = 'In Progress';
                  objNewSIN.c2g__InvoiceDate__c = date.newinstance(so.Ordered_Date__c.year(), so.Ordered_Date__c.month(), so.Ordered_Date__c.day()); 
                  objNewSIN.c2g__DeriveDueDate__c = false;
                  objNewSIN.c2g__DueDate__c = date.newinstance(so.Ordered_Date__c.year(), so.Ordered_Date__c.month(), so.Ordered_Date__c.day()); //system.today();
                  lstNewSIN.add(objNewSIN);

Actually i am creating SIN from two places one with above code and second SIN Creation with below code but this sin was able to post.

c2g__codaInvoice__c objSIN = new c2g__codaInvoice__c();
                objSIN.c2g__OwnerCompany__c = objSI.Company__c;
                objSIN.Company1__c = objSI.Company__c;
                objSIN.c2g__Account__c = objSI.Bill_To__c;
                objSIN.CurrencyIsoCode = objSI.CurrencyIsoCode;
                //modification
                objSIN.SO_Invoice__c = objSI.Id;
                if(objSI.CurrencyIsoCode != null && objSI.CurrencyIsoCode != 'RMB' && objSI.CurrencyIsoCode != '' &&  mapCurrency != null && mapCurrency.get(objSI.CurrencyIsoCode+'-'+objSI.Company__c) != null) {
                    objSIN.Accounting_Currency__c = mapCurrency.get(objSI.CurrencyIsoCode+'-'+objSI.Company__c).id;
                    objSIN.c2g__InvoiceCurrency__c = mapCurrency.get(objSI.CurrencyIsoCode+'-'+objSI.Company__c).id;
                }
                else if(objSI.CurrencyIsoCode != null && objSI.CurrencyIsoCode == 'RMB' && objSI.CurrencyIsoCode != '' &&  mapCurrency != null && mapCurrency.get('CNY'+'-'+objSI.Company__c) != null) {
                    objSIN.Accounting_Currency__c = mapCurrency.get('CNY'+'-'+objSI.Company__c).id;
                    objSIN.c2g__InvoiceCurrency__c = mapCurrency.get('CNY'+'-'+objSI.Company__c).id;
                }
                objSIN.Sales_Order__c = objSI.SO_number__c;
                objSIN.c2g__InvoiceDate__c = date.newinstance(objSI.Invoiced_Date__c.year(), objSI.Invoiced_Date__c.month(), objSI.Invoiced_Date__c.day()); 
                objSIN.c2g__InvoiceStatus__c = 'In Progress'; 
                objSIN.c2g__DeriveDueDate__c = false;
                objSIN.PL_number__c = objSI.PL_number__c; //added 01/12/2016 
                objSIN.c2g__DueDate__c = date.newinstance(objSI.Due_Date__c.year(), objSI.Due_Date__c.month(), objSI.Due_Date__c.day()); 
                objSIN.Sales_Order_1__c = objSI.BID_SO__c;
                lstSInv.add(objSIN);

Please help me to find: what should be the mandatory to post SIN and my SIN has period selection to post but still it is giving error while posting SIN. Financialforce.com guys really didnt provide relevant error messages to fix. 


 
  • January 30, 2016
  • Like
  • 0
Hi there everyone,

I'm new to Salesforce and Visualforce development. Though I have been doing C# for years in the Windows environment, my experience in web development is pretty limited. I am trying to build a solution where there are two picklists. The first pick list (OCS Units) is based on a 'Global pick list'. The second pick list should be loaded based on the value picked in the first pick list. When I run my code, it doesn't look like even the first pick list is being populated because when I click on the 'drop down' arrow, nothing is displayed.

Below is my Visualforce code:
 
<apex:page controller="OCSPicklistLoader">
    <apex:form>
        <apex:pageBlock>
            <apex:pageBlockSection columns="2">
            	<apex:pageBlockSectionItem>
                    <apex:outputLabel value="OCS Unit"/>
                </apex:pageBlockSectionItem>
            	<apex:pageBlockSectionItem>
                    <apex:selectList size="1" value="{!OCS_Unit}">
                    	<apex:selectOptions value="{!OCS_Unit}"/>
                    	<apex:actionSupport event="onchange" reRender="Offices"/>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem>
                    <apex:outputLabel value="OCS Office"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem>
                    <apex:selectList size="1" value="{!OCS_Office}" id="Offices">
                    	<apex:selectOptions value="{!OCS_Office}"/>
                    </apex:selectList>
                </apex:pageBlockSectionItem>    
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Below is my Controller code:
public class OCSPicklistLoader {
    public string OCS_Unit {get;set;}
    public string OCS_Office {get;set;}
    public List<OCS_Office__c> OCSOffices;
     
    public List<SelectOption> OCS_Unit()
    {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('A','None'));
        options.add(new SelectOption('B','FAT'));
        options.add(new SelectOption('C','SSU'));
        options.add(new SelectOption('D','EOU'));
        options.add(new SelectOption('E','EPMU'));
        options.add(new SelectOption('F','CIAU'));
        options.add(new SelectOption('G','JGO'));
        return options;
    }
    public List<SelectOption> OCS_Office()
    {
        List<SelectOption> options = new List<SelectOption>();

        OCSOffices = [select Name from OCS_Office__c WHERE OCS_Unit_Code__c=:OCS_Unit]; 
        for(OCS_Office__c a : OCSOffices)
        {
            options.add(new SelectOption(a.Name,a.Name));
        } 
        return options;
		
    }
	
}
Any assistance would be greatly appreciated.

Thanks!

Eric

Please let me know the simplest way(FREE) integrating SALESFORCE TO MAGENTO..

 

 

 

 

Thanks in advance,,!!!!