• Hersh321
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
Hi Everyone,

Does anyone know how to bind the xml attribute to a Salesforce field.  For some reason all the records that are being created are null.  I am trying to get the player name and id.  

xml:

<?xml version="1.0" encoding="UTF-8"?>
<team xmlns="http://feed.elasticstats.com/schema/nfl/roster-v1.0.xsd" id="BAL" name="Ravens" market="Baltimore">
  <player id="c5dfc54e-fd64-468f-81a8-073918776412" name_full="Bernard Pierce" name_first="Bernard" name_last="Pierce" name_abbr="B.Pierce" birthdate="1990-05-10" birth_place="Ardmore, PA, USA" high_school="Glen Mills (PA)" height="72" weight="218" college="Temple" position="RB" jersey_number="30" status="ACT" salary="0" experience="2" draft_pick="84" draft_round="3" draft_team="BAL">
    <injuries>
      <injury id="b7fec083-21c4-4244-a705-d5af4b024f41" start_date="2014-09-18T00:00:00+00:00" game_status="PRO" practice_status="Full Participation">
        <description>Thigh</description>
        <notes>
</notes>
      </injury>
    </injuries>
  </player>
       
Apex:

        Http h = new Http();
       
        HttpRequest req = new HttpRequest();
        req.setEndpoint(url);
        req.setMethod('GET');
       
        HttpResponse res = h.send(req);
        Dom.Document docx = res.getBodyDocument();

        dom.XmlNode xroot = docx.getrootelement() ;
       
        dom.XmlNode [] xrec = xroot.getchildelements() ; //Get all Record Elements
       
        for(Dom.XMLNode child : xrec) //Loop Through Records
        {
         Roster__c rstr = new Roster__c();
       
          for (dom.XmlNode awr : child.getchildren() ) {
                                 if (awr.getname() == 'player') {
                                        rstr.PlayerID__c = awr.getAttributeValue ('id',null);
         } 
             
                                 if (awr.getname() == 'player') {
                                       rstr.Full_Name__c = awr.getAttributeValue ('name_full',null);
         } 
       
       
        }
        newroster.add(rstr);
        }
        system.debug(newroster);//you could insert here or upsert based on ID with an external Id field
        upsert newroster;
   }

Hi Everyone,

 

I'm trying to create a custome report via Visualforce.  I have a custom object called Quota's.  For each month I'm trying to sum all the closed opp amount values per a particular user and divide it by the users quota for that month.

 

EX: Jims Quota for January is $10,000.  He has Closed $20,000.  So his % is 200% for January.  I'm geting all the values correct but it shows 200% for everyone in the Jan column.  I've tried converting values into a string and storing them in a list but i can't seem to get it working properly.  I've attached the code on the bottom.  Any help is greatly appreciated.

 

-Hersh

 

Class:

 

public class QuotaReport {
    
    public User[] SalesRep            {get; set;}
    public Opportunity[] OppList      {get; set;}
    public Quota_Custom__c[] Quota    {get; set;}
    public decimal Jan                {get; set;}
    public decimal Feb                {get; set;}
    public decimal Mar                {get; set;}
    public decimal Apr                {get; set;}
    public decimal May                {get; set;}
    public decimal Jun                {get; set;}
    public decimal Jul                {get; set;}
    public decimal Aug                {get; set;}
    public decimal Sept               {get; set;}
    public decimal Oct                {get; set;}
    public decimal Nov                {get; set;}
    public decimal Dec                {get; set;}
    public String CurrYear = String.valueOf(Date.today().year());
    Public Date Jan1 = Date.valueOf(CurrYear+'-01-01');
    Public Date Jan31 = Date.valueOf(CurrYear+'-01-31');   
    Public Date Feb1 = Date.valueOf(CurrYear+'-02-01');
    Public Date Feb28 = Date.valueOf(CurrYear+'-02-28');   
    Public Date Mar1 = Date.valueOf(CurrYear+'-03-01');
    Public Date Mar31 = Date.valueOf(CurrYear+'-03-31');   
    Public Date Apr1 = Date.valueOf(CurrYear+'-04-01');
    Public Date Apr30 = Date.valueOf(CurrYear+'-04-30');
    Public Date May1 = Date.valueOf(CurrYear+'-05-01');
    Public Date May31 = Date.valueOf(CurrYear+'-05-31');
    Public Date Jun1 = Date.valueOf(CurrYear+'-06-01');
    Public Date Jun30 = Date.valueOf(CurrYear+'-06-30');
    Public Date Jul1 = Date.valueOf(CurrYear+'-07-01');
    Public Date Jul31 = Date.valueOf(CurrYear+'-07-31');
    Public Date Aug1 = Date.valueOf(CurrYear+'-08-01');
    Public Date Aug31 = Date.valueOf(CurrYear+'-08-31');
    Public Date Sept1 = Date.valueOf(CurrYear+'-09-01');
    Public Date Sept30 = Date.valueOf(CurrYear+'-09-30');
    Public Date Oct1 = Date.valueOf(CurrYear+'-10-01');
    Public Date Oct31 = Date.valueOf(CurrYear+'-10-31');
    Public Date Nov1 = Date.valueOf(CurrYear+'-11-01');
    Public Date Nov30 = Date.valueOf(CurrYear+'-11-30');
    Public Date Dec1 = Date.valueOf(CurrYear+'-12-01');
    Public Date Dec31 = Date.valueOf(CurrYear+'-12-31');
    
    public QuotaReport(){
    
        SalesRep = [Select Id, Name, ProfileId FROM User];


        Quota = [Select Id, Name, January__c, February__c, March__c, April__c, May__c, June__c, July__c, August__c, September__c, October__c, November__c, December__c, Year__c, Salesperson__c, Salesperson__r.Name FROM Quota_Custom__c WHERE Year__c=:CurrYear AND Salesperson__c=:Salesrep];


        OppList = [Select Id, Name, OwnerId, CloseDate, StageName, Closed_Deal_Booking_Value__c, Amount, CreatedDate FROM Opportunity WHERE OwnerID=:Salesrep];
        
        //List<String> Jan=new List<String>();
        
        //for(User USR : SalesRep){
        
            for(Quota_Custom__c UsrSP : Quota){
            
                for(Opportunity Opp : OppList) {

                    if(Opp.CloseDate > Jan1 && Opp.CloseDate < Jan31){

                       Jan=(Opp.Closed_Deal_Booking_Value__c/UsrSP.January__c)*100;
                        //Jan.add(string.ValueOf((Opp.Closed_Deal_Booking_Value__c/UsrSP.January__c)*100));
                    }
                    if(Opp.CloseDate > Feb1 && Opp.CloseDate < Feb28){
                    
                        Feb= (Opp.Closed_Deal_Booking_Value__c/UsrSP.February__c)*100;
                    }
                    if(Opp.CloseDate > Mar1 && Opp.CloseDate < Mar31){
                    
                        Mar= (Opp.Closed_Deal_Booking_Value__c/UsrSP.March__c)*100;
                    }
                    if(Opp.CloseDate > Apr1 && Opp.CloseDate < Apr30){
                    
                        Apr= (Opp.Closed_Deal_Booking_Value__c/UsrSP.April__c)*100;
                    }
                    if(Opp.CloseDate > May1 && Opp.CloseDate < May31){
                    
                        May= (Opp.Closed_Deal_Booking_Value__c/UsrSP.May__c)*100;
                    }
                    if(Opp.CloseDate > Jun1 && Opp.CloseDate < Jun30){
                    
                        Jun= (Opp.Closed_Deal_Booking_Value__c/UsrSP.June__c)*100;
                    }
                    if(Opp.CloseDate > Jul1 && Opp.CloseDate < Jul31){
                    
                        Jul= (Opp.Closed_Deal_Booking_Value__c/UsrSP.July__c)*100;
                    }
                    if(Opp.CloseDate > Aug1 && Opp.CloseDate < Aug31){
                    
                        Aug= (Opp.Closed_Deal_Booking_Value__c/UsrSP.August__c)*100;
                    }
                    if(Opp.CloseDate > Sept1 && Opp.CloseDate < Sept30){
                    
                        Sept= (Opp.Closed_Deal_Booking_Value__c/UsrSP.September__c)*100;
                    }
                    if(Opp.CloseDate > Oct1 && Opp.CloseDate < Oct31){
                    
                        Oct= (Opp.Closed_Deal_Booking_Value__c/UsrSP.October__c)*100;
                    }
                    if(Opp.CloseDate > Nov1 && Opp.CloseDate < Nov30){
                    
                        Nov= (Opp.Closed_Deal_Booking_Value__c/UsrSP.November__c)*100;
                    }
                    if(Opp.CloseDate > Dec1 && Opp.CloseDate < Dec31){
                    
                        Dec= (Opp.Closed_Deal_Booking_Value__c/UsrSP.December__c)*100;
                    }
                }
            }
       // }
    }
}

 

VF:

 

<apex:page controller="QuotaReport">
<apex:pageBlock >
<apex:dataTable value="{!Salesrep}" var="Table" cellpadding="5">
<apex:facet name="header"><apex:outputText value="Quota Report" escape="false"/></apex:facet>
<apex:column width="10%">
<apex:facet name="header">Sales Person</apex:facet>
<apex:OutputText value="{!Table.Name}" />
</apex:column>
<apex:column width="10%">
<apex:facet name="header">Jan</apex:facet>
<apex:OutputText value="{!Jan}%" />
</apex:column>
<apex:column width="10%">
<apex:facet name="header">Feb</apex:facet>
<apex:OutputText value="{!Feb}%" />
</apex:column>
<apex:column width="10%">
<apex:facet name="header">Mar</apex:facet>
<apex:OutputText value="{!Mar}%" />
</apex:column>
<apex:column width="10%">
<apex:facet name="header">Apr</apex:facet>
<apex:OutputText value="{!Apr}%" />
</apex:column>
<apex:column width="10%">
<apex:facet name="header">May</apex:facet>
<apex:OutputText value="{!May}%" />
</apex:column>
<apex:column width="10%">
<apex:facet name="header">Jun</apex:facet>
<apex:OutputText value="{!Jun}%" />
</apex:column>
<apex:column width="10%">
<apex:facet name="header">Jul</apex:facet>
<apex:OutputText value="{!Jul}%" />
</apex:column>
<apex:column width="10%">
<apex:facet name="header">Aug</apex:facet>
<apex:OutputText value="{!Aug}%" />
</apex:column>
<apex:column width="10%">
<apex:facet name="header">Sept</apex:facet>
<apex:OutputText value="{!Sept}%" />
</apex:column>
<apex:column width="10%">
<apex:facet name="header">Oct</apex:facet>
<apex:OutputText value="{!Oct}%" />
</apex:column>
<apex:column width="10%">
<apex:facet name="header">Nov</apex:facet>
<apex:OutputText value="{!Nov}%" />
</apex:column>
<apex:column width="10%">
<apex:facet name="header">Dec</apex:facet>
<apex:OutputText value="{!Dec}%" />
</apex:column>
</apex:dataTable>
</apex:pageBlock>
</apex:page>