• jeremy_w
  • NEWBIE
  • 10 Points
  • Member since 2008

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

Hi

 

I've created the following query to tell me "how many contacts have been assigned to a case in the date period passed in for the account passed in". However I'm not convinced it's correct:

 

 

Integer SFuserscases=[SELECT count() FROM Contact WHERE (AccountId=:acctID) AND (Id in (SELECT ContactId FROM Case WHERE AccountId=:acctID and (CreatedDate>=:RdsDT and CreatedDate<:RdeDT)))];

 

 

Can someone comment and perhaps improve it if it's not quite right?

 

Thanks

Jeremy

 

Message Edited by jeremy_w on 07-06-2009 08:14 AM
Message Edited by jeremy_w on 07-06-2009 08:14 AM

I'm building a customer portal onto our existing salesforce. 

I've a visualforce page that overrides the case view page (cases>buttons and links) that was built for internal use.

I've added a new case page for portal users and assigned it to the portal users in the page layouts area (cases>page layouts).

 

I need to give the portal users a different case view page for obvious reasons but cannot find a way to do this.

 

I spoke with support and they suggested the discussion boards....

 

Is this possible? It seems that the "buttons and links" is conflicts with "page layouts".

 

Thanks

Jeremy

 

 

 

I've overridden the standard case view with a visualforce page.
I've got a list of tasks in that page that relate to the case.

I'd like to add a standard button to add a new task (just like on the normal "open activities" detail page).

What's the best way to do this?

Also how can I re-order the data shown in a pageBlockTable (ordered by one of the displayed columns in this case)?

Code below:

Code:
<apex:page standardController="Case" showHeader="true" sidebar="true" tabStyle="Case"> 
<style>
.activeTab {background-color:#ef2b2d;color:white;background-image:none;}
.inactiveTab {background-color:lightgrey;color:black;background-image:none;}
</style>
<apex:tabPanel switchType="client" selectedTab="tabdetails" id="CaseTabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab">
        <apex:tab label="Details" name="CaseDetails" id="tabdetails"> 
                <apex:detail relatedList="false" title="true"></apex:detail> 

                <apex:pageBlock title="Tasks">
                    <apex:pageblockTable value="{!Case.Tasks}" var="s" columns="3">
                        <apex:column width="100">
                            <apex:outputField value="{!s.DateForTimeRecording__c}" />
                        </apex:column>
                        <apex:column width="120">{!s.Owner.Name}</apex:column>
                        <apex:column >{!s.Subject}</apex:column>
                        <apex:column breakBefore="true">&nbsp;</apex:column>
                        <apex:column colspan="2">{!s.Description} </apex:column>
                    </apex:pageblockTable>
                </apex:pageBlock>
        </apex:tab> 
        <apex:tab label="Open Activities" name="OpenActivities" id="tabOpenAct">
                <apex:relatedList list="OpenActivities" pageSize="20"></apex:relatedList> 
        </apex:tab> 
</apex:tabPanel>
</apex:page>

 

Hi
 
I've created this trigger to update the total time for a case based on the times in all the tasks (custom fields).
But I couldn't work out how to use "What.type" to only run the code for tasks associated to cases (I've got a workaround in there as you can see).
Code:
trigger TaskTriggerAfter on Task (after insert, after update, after delete) {
 for (Task task : Trigger.new) {
  String acctID=task.accountid;
  String caseID='';

  Task[] task2 = [select Id from task where (Id=:task.id) AND (What.Type = 'Case')];
  if (task2.size()>0) {
   caseID = task.WhatId;
   Task[] tasks = [select Total_Time_Spent_hours__c from task where WhatId=:caseID];
   Decimal TotalTimeSpent = 0;
   for (Task t : tasks) {
    TotalTimeSpent = TotalTimeSpent + t.Total_Time_Spent_hours__c;
   }
   Case cas = [select Id,TotalTimeSpent__c from Case WHERE Id=:caseID];
   cas.TotalTimeSpent__c = TotalTimeSpent;
   update cas;
  } 
 }
}
 I thought:
  if (task.What.type == 'Case') { would work (replacing the task2 stuff) but it didn't.
So I tried to find out if I got a result from the query but couldn't unless I did it using size (even though only 1 result max will be returned).
Maybe something based on the caseID would be possible: if (caseID.length() )? (I'm not sure about the string functions).
 
If anyone has advice on more efficient ways to code this then please do let me know. Also any links to descriptions of string functions in Apex as I can't find any (such as length).
 
And finally, I've read that you should code triggers to allow for bulk updates, but when will/how can bulk updates occur? (I tried to do a replacement of a picklist value but that only seems to replace the value and the last modified date - it doesn't run the triggers).
 
Thanks.
 


Message Edited by jeremy_w on 03-29-2008 07:01 PM
Hi
 
I've created this trigger to update the total time for a case based on the times in all the tasks (custom fields).
But I couldn't work out how to use "What.type" to only run the code for tasks associated to cases (I've got a workaround in there as you can see).
Code:
trigger TaskTriggerAfter on Task (after insert, after update, after delete) {
 for (Task task : Trigger.new) {
  String acctID=task.accountid;
  String caseID='';

  Task[] task2 = [select Id from task where (Id=:task.id) AND (What.Type = 'Case')];
  if (task2.size()>0) {
   caseID = task.WhatId;
   Task[] tasks = [select Total_Time_Spent_hours__c from task where WhatId=:caseID];
   Decimal TotalTimeSpent = 0;
   for (Task t : tasks) {
    TotalTimeSpent = TotalTimeSpent + t.Total_Time_Spent_hours__c;
   }
   Case cas = [select Id,TotalTimeSpent__c from Case WHERE Id=:caseID];
   cas.TotalTimeSpent__c = TotalTimeSpent;
   update cas;
  } 
 }
}
 I thought:
  if (task.What.type == 'Case') { would work (replacing the task2 stuff) but it didn't.
So I tried to find out if I got a result from the query but couldn't unless I did it using size (even though only 1 result max will be returned).
Maybe something based on the caseID would be possible: if (caseID.length() )? (I'm not sure about the string functions).
 
If anyone has advice on more efficient ways to code this then please do let me know. Also any links to descriptions of string functions in Apex as I can't find any (such as length).
 
And finally, I've read that you should code triggers to allow for bulk updates, but when will/how can bulk updates occur? (I tried to do a replacement of a picklist value but that only seems to replace the value and the last modified date - it doesn't run the triggers).
 
Thanks.
 


Message Edited by jeremy_w on 03-29-2008 07:01 PM
How do i get Sales Force and Google Adwords working on a form on my website that's built the asp.net platform, and the form submit code is handled in the code file (VB)?

Before sending the form data to Sales Force, I process the form data into the site's database and send confirmation emails. After that I send the form data over to Sales Force via the System.Net.WebClient object.

Sales Force receives the Lead data (so i know it makes it to Sales Force) but this data is not going into the Adwords section.

Sales Force/Adwords help pages only show how to pass the forms over via javascript and the Post attribute.

There has to be a way to send over the data via the code side (VB) and get it insert into the Google Adwords portion of Sales Force. Can anyone help?

I'm building a customer portal onto our existing salesforce. 

I've a visualforce page that overrides the case view page (cases>buttons and links) that was built for internal use.

I've added a new case page for portal users and assigned it to the portal users in the page layouts area (cases>page layouts).

 

I need to give the portal users a different case view page for obvious reasons but cannot find a way to do this.

 

I spoke with support and they suggested the discussion boards....

 

Is this possible? It seems that the "buttons and links" is conflicts with "page layouts".

 

Thanks

Jeremy

 

 

 

Hey
Im trying to add a new field called contract term to the quote app. I've successfully added it to
addProductsToQuote and editLineItems s-controls. when i try to add it to quoteLinesToOppRecordV3.htm s-control I get an error message. the code im using for this is p.set("Contract",q.get("Contract__c"));  it throws out an exception only if the word "contract" is used.
any ideas
thanks
Hello.  We had installed Case History Timeline and were happily using it.   We are not sure what changed but now when we click on the Case Timeline link within our cases, the window for the case timeline launches but there is no case timeline data within in.   The bottom of the window says "done".   There should definitely be case timeline history, both public and private.   We have calls and emails and comments within the case.  Any idea of what we should do to troubleshoot?
Thanks!
I have an s-control that uses the AJAX proxy remoteFunction to connect to an external URL.  It has been working correctly for several months.  Over night the remoteFunction stopped working and only returns a read timeout error.
 
"400 Unable to forward request due to: Read timed out"
 
 I have eliminated and/or tested all of the other factors: connection to external site, browser, data error, IP address whitelists, etc.  I have tried using version 11 and 12 of the API.  I have also contacted the Sales Force support line with no avail.  I know that this can occur when Sales Force slows down, but it has never happened for this long 12+ hours.
 
I am left to assume that some issue with Sales Force occurred over night.  Any Ideas?
 
Code:
function postRequest(envelope) {

 sforce.connection.remoteFunction({
  url : "https://<deleted>",
  requestHeaders: {
   "Content-Type":"application/x-www-form-urlencoded; charset=utf-8"
  },
  requestData: envelope,
  method: "POST",
  onSuccess : postSuccess,
  onFailure : postFailure
 });

} 

I'm having trouble developing an S-Control to keep a link between Leads and Accounts for a Custom Object.
 
The basic situation is this:
 
The custom object is connected to both the Leads and Accounts Tabs but when the Lead is converted the Custom Object never establishes a connection to the new Account created.
 
I'm hoping there's a way to create this link upon conversion but I'd settle for anything that allows for the connection to be established without having to manually click on the field and lookup the newly created Account for evey single Custom Object.
 
I've started working on a Custom S-Control but if someone has already developed this I'd love some assistance with what has previous worked in order to adapt to our Salesforce.com system.
 
This is the first time I've posted on the community but it appears that this is a pretty successful place for getting questions answered and assistance for those new to manually programming the system.
I've overridden the standard case view with a visualforce page.
I've got a list of tasks in that page that relate to the case.

I'd like to add a standard button to add a new task (just like on the normal "open activities" detail page).

What's the best way to do this?

Also how can I re-order the data shown in a pageBlockTable (ordered by one of the displayed columns in this case)?

Code below:

Code:
<apex:page standardController="Case" showHeader="true" sidebar="true" tabStyle="Case"> 
<style>
.activeTab {background-color:#ef2b2d;color:white;background-image:none;}
.inactiveTab {background-color:lightgrey;color:black;background-image:none;}
</style>
<apex:tabPanel switchType="client" selectedTab="tabdetails" id="CaseTabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab">
        <apex:tab label="Details" name="CaseDetails" id="tabdetails"> 
                <apex:detail relatedList="false" title="true"></apex:detail> 

                <apex:pageBlock title="Tasks">
                    <apex:pageblockTable value="{!Case.Tasks}" var="s" columns="3">
                        <apex:column width="100">
                            <apex:outputField value="{!s.DateForTimeRecording__c}" />
                        </apex:column>
                        <apex:column width="120">{!s.Owner.Name}</apex:column>
                        <apex:column >{!s.Subject}</apex:column>
                        <apex:column breakBefore="true">&nbsp;</apex:column>
                        <apex:column colspan="2">{!s.Description} </apex:column>
                    </apex:pageblockTable>
                </apex:pageBlock>
        </apex:tab> 
        <apex:tab label="Open Activities" name="OpenActivities" id="tabOpenAct">
                <apex:relatedList list="OpenActivities" pageSize="20"></apex:relatedList> 
        </apex:tab> 
</apex:tabPanel>
</apex:page>

 

I wrote the following trigger.

Code:
trigger Create_CampaignMember_For_New_Leads on Lead (after insert) {
 
 List <CampaignMember> cm = new list<CampaignMember>();
 
 for(Lead L : Trigger.new) {
  
  String cname = L.leadsource;
  
  List <Campaign> c = [select id, name from Campaign where name = :cname limit 1];
  
  if(!c.isEmpty()){
   CampaignMember cml = new CampaignMember();
   cml.campaignid = c[0].id;
   cml.leadid = l.id;
   cm.add(cml);
  }
 }
 
 if(!cm.isEmpty()){
  insert cm;
 }
}

 
The code adds a Campaign Member record automatically if it can find a Campaign with a name matching the Lead Source name. 

All is great when I use the application and with web-to-lead.  However, License Manager submitted a Lead/License today and I got the following email.

Code:
Apex script unhandled trigger exception by user/organization: 0053000000125N9/00D300000007gjY

Create_CampaignMember_For_New_Leads: compiling trigger body

caused by: line 15, column 29: sObject type 'Campaign' is not supported.

 
That user id is one of the License Manager users that gets created behind the scenes.  The end result is that the License record gets created, but the Lead does not.

Is there anything I can do to make this get fixed?  I was thinking I could edit the API Access Restrictions on the License Manager installed package to give access to Campaigns.  Will that help?

If that won't help, do I need to edit my Apex Code to do a user lookup to make sure it's not an LMA user?  Or can I do a describeGlobal type of query to make sure the user has access to Campaign?  If that's the route to take, I could use a little help.

Thanks.
  • April 20, 2008
  • Like
  • 0
Hello.

I have had nothing but trouble deploying/updating/activating triggers in EE (no problem in DE).  I check the forums and found many people saying the same thing.  However I assume than most people are able to deploy/run triggers in EE without a problem?  Please respond if you're able to reliably work with Apex in EE.

Thanks
Chris


  • April 15, 2008
  • Like
  • 0
Is there a way to get the defined List Views for a given object type via the Partner API?  I would like to take advantage of any defined lists so that I can retreive the same lists via the API.  I would be happy if I could retreive the name and the actual query.  The list of sObjects for a given a view would even be nicer...
 
Thanks,
Greg
  • January 21, 2008
  • Like
  • 0
Hi,
 
I am trying to store current date into one of the custom date field at Opportunity object. I am using the code below: -
 
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<script type="text/javascript" src="/js/functions.js"></script> 
<script src="/soap/ajax/9.0/connection.js"></script> 
<script language="javascript"> 

function saveRec() 
{ 
var opp = new sforce.SObject("Opportunity"); 
opp.set("Id", "{!Opportunity.Id}"); 

var mydate=new Date() 
var year=mydate.getYear() 
if (year < 1000) 
year+=1900 
var day=mydate.getDay() 
var month=mydate.getMonth()+1 
if (month<10) 
month="0"+month 
var daym=mydate.getDate() 
if (daym<10) 
daym="0"+daym 

var date1=month+"/"+daym+"/"+year; // this returns eg. 05/09/2007

opp.set("Questionnaire_Back__c",date1); 

 
I am getting error "05/09/2007' is not a valid for the type 'xsd:date'. Any idea where I am doing mistake? Do you have any example of updating date field?
 
Thanks in advance.
 
  • May 09, 2007
  • Like
  • 0