• Chad Kovac
  • NEWBIE
  • 20 Points
  • Member since 2014
  • Salesforce Admin / Sr. Analyst
  • Fleet Advantage, LLC

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 17
    Replies

Using this code, I can get the day of the month but I need to say: 2nd, not 2 and 3rd not 3, etc.,

<apex:outputText value="{0, date, D}"><apex:param value="{!Date()}" /></apex:outputText>

Someone on Stack Exchange recommended this Javascript embedded in my page:
<Script Language="JavaScript">
public static String getDayOfMonthSuffix(Integer n) {
    if (n == null) {
        return '';
    }

    if (n >= 11 && n <= 13) {
        return 'th';
    }

    Integer modResult = Math.mod(n, 10);        
    if (modResult == 1) { 
        return 'st'; 
    } else if (modResult == 2) { 
        return 'nd'; 
    } else if (modResult == 3) { 
        return 'rd'; 
    } else { 
        return 'th';
    }
}</script>

html starting...
IN WITNESS WHEREOF, the Parties have executed this Confidentiality Agreement under seal as of this 
<Script Language="JavaScript">
    getDayOfMonthSuffix(getUTCDate());
</Script>
day of .... more html




My org has 16 licenses and only about 7 actually active users.
Those active users are salesmen in the field using Salesforce1 and Outlook integration.
I am constantly on the high end of API calls personally with the rest falling to the salesmen.
My org is constantly at 85-95% of the allowable API calls.

How can we reduce this?
We use the Salesforce for Outlook application and some of us use Chatter for Desktop.

It seems unusual that my org is constantly up against the API limit when there are so many other orgs out there using Salesforce and I don't see a lot in the way of complaints from them so we have to be doing something wrong.

Using the example here:
http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_dataTable.htm

I'm trying to get the following code to work:


Now, I this is only the first step.  I also have Opportunity_SubGroup__c that exist under Opportunity_Group__c
Apex page:
<apex:page controller="oppHierarchy" id="thePage">
	<apex:dataTable value="{!OGs}" var="Opportunity" id="theTable" rowClasses="odd,even" styleClass="tableClass">
		<apex:facet name="caption">table caption</apex:facet>
		<apex:facet name="header">table header</apex:facet>
		<apex:facet name="footer">table footer</apex:facet>
		<apex:column>
		        <apex:facet name="header">Name</apex:facet>
			<apex:facet name="footer">column footer</apex:facet>
			<apex:outputText value="{!OGs.name}"/>
		</apex:column>
		<apex:column>
			<apex:facet name="header">Quantity</apex:facet>
			<apex:facet name="footer">column footer</apex:facet>
			<apex:outputText value="{!OGs.Quantity__c}"/>
		</apex:column>
	</apex:dataTable>
</apex:page>
Class:
public class oppHierarchy {
	List<Opportunity_Group__c> OGs;
	public List<Opportunity_Group__c> getOGs() {
		if(OGs == null) OGs = [select name, Quantity__c from Opportunity_Group__c limit 10];
		return OGs;
	}
}


Ideally, I'll need to list related groups and subgroups on the opportunity page.

Maybe something like these will be needed in my Class?
public List<Task> getRelatedTasks() {
        return [select Id, Subject, ActivityDate, Status, Owner.Name, What.Name, Account.name, Type, CallType from Task where AccountId in :AllIds Order By ActivityDate Desc];
         
    
    }
    public List<Event> getRelatedEvents() {
        return [select Id, Legacy_Calltype__c, Subject, Type, Event_Status__c, Owner.Name, What.Name, ActivityDate from Event where WhatId in :AllIds Order By ActivityDate Desc];
    }

Instead of Tasks and Events I'd need Opportunity_Groups__c and Opportunity_Subgroups__c


Any help?


I'm trying to update an Opportunity OEM_Make__c field with a comma delim list of Manufacturers from a Subgroup.  Opportunity->Group->SubGroup.

I receive no errors but it doesn't seem to be updating anything... ?
Opportunity_ID__c is the Opportunity ID that the Subgroup is related to (through the Group): Opportunity_Group__r.Opportunity__r.Id

trigger UpdateOEMonOpportunity on Opportunity_SubGroup__c (before insert, before update) {
String strOEMs;
String strComma;
Set<Id> OppIds = new Set<Id>();
for (Opportunity_Subgroup__c sg : Trigger.new) {
  OppIds.add(sg.Opportunity_ID__c);
}

strOEMs = Null;
strComma = Null;

List<Opportunity> Opps = new List<Opportunity>{};

if (OppIds.size() > 0) {
  for(Opportunity_SubGroup__c OSG : [Select Opportunity_ID__c, Manufacturer__c from Opportunity_Subgroup__c where Opportunity_ID__c in :OppIds]) {
   if(OSG.Manufacturer__c!=Null) {
    strOEMs=strOEMs + strComma + OSG.Manufacturer__c;
          strComma = ', ';
   }
   Opps.Add(
    new Opportunity(
     OEM_Make__c = strOEMs,
     ID=OSG.Opportunity_ID__c
    ));
  }
  if(!Opps.IsEmpty()) {Update Opps;}
}
}


My org has 16 licenses and only about 7 actually active users.
Those active users are salesmen in the field using Salesforce1 and Outlook integration.
I am constantly on the high end of API calls personally with the rest falling to the salesmen.
My org is constantly at 85-95% of the allowable API calls.

How can we reduce this?
We use the Salesforce for Outlook application and some of us use Chatter for Desktop.

It seems unusual that my org is constantly up against the API limit when there are so many other orgs out there using Salesforce and I don't see a lot in the way of complaints from them so we have to be doing something wrong.

Using the example here:
http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_dataTable.htm

I'm trying to get the following code to work:


Now, I this is only the first step.  I also have Opportunity_SubGroup__c that exist under Opportunity_Group__c
Apex page:
<apex:page controller="oppHierarchy" id="thePage">
	<apex:dataTable value="{!OGs}" var="Opportunity" id="theTable" rowClasses="odd,even" styleClass="tableClass">
		<apex:facet name="caption">table caption</apex:facet>
		<apex:facet name="header">table header</apex:facet>
		<apex:facet name="footer">table footer</apex:facet>
		<apex:column>
		        <apex:facet name="header">Name</apex:facet>
			<apex:facet name="footer">column footer</apex:facet>
			<apex:outputText value="{!OGs.name}"/>
		</apex:column>
		<apex:column>
			<apex:facet name="header">Quantity</apex:facet>
			<apex:facet name="footer">column footer</apex:facet>
			<apex:outputText value="{!OGs.Quantity__c}"/>
		</apex:column>
	</apex:dataTable>
</apex:page>
Class:
public class oppHierarchy {
	List<Opportunity_Group__c> OGs;
	public List<Opportunity_Group__c> getOGs() {
		if(OGs == null) OGs = [select name, Quantity__c from Opportunity_Group__c limit 10];
		return OGs;
	}
}


Ideally, I'll need to list related groups and subgroups on the opportunity page.

Maybe something like these will be needed in my Class?
public List<Task> getRelatedTasks() {
        return [select Id, Subject, ActivityDate, Status, Owner.Name, What.Name, Account.name, Type, CallType from Task where AccountId in :AllIds Order By ActivityDate Desc];
         
    
    }
    public List<Event> getRelatedEvents() {
        return [select Id, Legacy_Calltype__c, Subject, Type, Event_Status__c, Owner.Name, What.Name, ActivityDate from Event where WhatId in :AllIds Order By ActivityDate Desc];
    }

Instead of Tasks and Events I'd need Opportunity_Groups__c and Opportunity_Subgroups__c


Any help?


I'm trying to update an Opportunity OEM_Make__c field with a comma delim list of Manufacturers from a Subgroup.  Opportunity->Group->SubGroup.

I receive no errors but it doesn't seem to be updating anything... ?
Opportunity_ID__c is the Opportunity ID that the Subgroup is related to (through the Group): Opportunity_Group__r.Opportunity__r.Id

trigger UpdateOEMonOpportunity on Opportunity_SubGroup__c (before insert, before update) {
String strOEMs;
String strComma;
Set<Id> OppIds = new Set<Id>();
for (Opportunity_Subgroup__c sg : Trigger.new) {
  OppIds.add(sg.Opportunity_ID__c);
}

strOEMs = Null;
strComma = Null;

List<Opportunity> Opps = new List<Opportunity>{};

if (OppIds.size() > 0) {
  for(Opportunity_SubGroup__c OSG : [Select Opportunity_ID__c, Manufacturer__c from Opportunity_Subgroup__c where Opportunity_ID__c in :OppIds]) {
   if(OSG.Manufacturer__c!=Null) {
    strOEMs=strOEMs + strComma + OSG.Manufacturer__c;
          strComma = ', ';
   }
   Opps.Add(
    new Opportunity(
     OEM_Make__c = strOEMs,
     ID=OSG.Opportunity_ID__c
    ));
  }
  if(!Opps.IsEmpty()) {Update Opps;}
}
}