• cmarzilli
  • NEWBIE
  • 4 Points
  • Member since 2006

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 23
    Replies

I want to loop through all the fields on an opportunity and if they are a multi select pick list, add their name to a list.  here is my non-working code:

 

        Schema.DescribeSObjectResult dsr = Opportunity.sObjectType.getDescribe();
        List<String>  MPL= new List<String>();
        for (Integer i=0; i < dsr.fields.Length; i++) {
                if( dsr.fields[i].getType == 'MultiPicklist'  )
                {
                    MPL.Items.Add( dsr.fields[i].getLabel  );
                }
            }

On the MPL.Items.Add( dsr.fields[i].getLabel  ) line I get the following error:

Error: Compile Error: Expression must be a list type: Schema.SObjectTypeFields at line 13 column 36 

 

From the documentation "getLabel" should return a string.  I don't know why it's asking for a list type. 

I have a custom Picklist (Multi-Select) and when a run a report that groups by the Picklist it doesn't group by each item in the Picklist but each combination of selected items that exist.
 
For example pick list values are A,B,C.
 
My report groups will list all select combinations 
A
ABC
AC
B
BC
C
 
Instead I want my groups A, B C. 
 
If an item as all three selected it should show up in each group.  Any ideas on how to do this?
I have an apex trigger that creates a new case and assigns it to a specific user.  What code would I use to tell Salesforce to send a notification email to the user?  In the Salesforce UI you can simply check off the "Send Notification Email" check box when assigning the case.
 
But my the page title comes out with a gray background (should be the same color as an account) and no icon! :robotmad:
 
Code:
<HTML>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<link href="/dCSS/Theme2/default/common.css" type="text/css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" >
<link href="/dCSS/Theme2/default/custom.css" type="text/css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" >
<BODY class=”account”>
<DIV class=bPageTitle>
 <DIV class="ptBody secondaryPalette">
 <DIV class=content><IMG class=pageTitleIcon alt=Entity_Name src="/s.gif">
 <H1 class=pageType>Account<SPAN class=titleSeparatingColon>:</SPAN></H1>
 <H2 class=pageDescription>Sign Up</H2>
 </DIV></DIV></DIV>

 All I did was cut and paste the code from the doc.  Anyone know what I am doing wrong?

 
I am trying to figure out a way to query my salesforce data for all opportunities that have less than 2 linked activities.  Anyone know how to do this?
I was looking for an easy way to map all of our Accounts (of a certain type) on a map.  Possibly color code by Account Owner.  I'd like to see this on a dashboard if possible.  Has any one done this or knows how to?  I saw a few app exchange apps but none that do this (I think)
First is this even possible?  I tried using an APEX trigger but the SelfServiceUser object is not avialable.
 
If it is possible can anyone figure out what is wrong with this script?  I am get an "Object Expected" error on line 40 which is the Body tag.
 
Code:
html>
<!--
Generated by AJAX tools
Date     :  Mon Apr 14 2008 14:54:35 GMT-0400 (Eastern Daylight Time)
Template :  simple.html by manoj@cheenath.com
SControl   :  ShutOffSelfService
 -->
<head><script  type="text/javascript">function getRecordIds(keyPrefix) { return [] }</script>
<script  type="text/javascript">__sfdcSessionId = '100d00D300000000PXI!AQEAQIIvyieXwYFnhWBj0aa_vaic3bxkoXnIjKlcP_DQ3u1hlr0eR95Ziqyh5ITLEe2nKuBWqOxk.aAG1GaLHELvCsPxW0q9'</script>

<script src="/soap/ajax/8.0/connection.js"></script>
<script src="/js/dojo/0.3.1/dojo.js"></script> 
<script src="/soap/ajax/8.0/apex.js"></script> 
<script>
function doit()
{
 var doc = document.getElementById("output");
 doc.innerHTML ="start";
 try
 {
  var result = sforce.connection.query("SELECT Id FROM Contact Where AccountId=00130000002Ufha");
  var it = new sforce.QueryResultIterator(result);
  while(it.hasNext())
  {
   var record = it.next();
   var ssu = sforce.connection.query("SELECT Id FROM SelfServiceUser WHERE Active=true AND ContactId=" + record.Id);

   ssu.Active = false;
   var result2 = sforce.connection.update([ssu]);
  }
 }
 catch (Exception e)
 {
  doc.innerHTML ="error";
 }
 doc.innerHTML ="done!";
}
</script> 
</head>
<body onload="doit()">
<div id="output"></div>
</body>
</html>

 
I am confused about the new Roll-up fields.  I would like to have an account field that gives me the total number of cases related to the account, can the new Roll-up fields do this?  If not how can I easily get this number on the account page?
Is this type of query even possible?  I keep getting the INVALID_TYPE error.
 
QUERY:
 
SELECT A.ID, A.Name, (SELECT C.ID, (Select S.ID FROM C.SelfServiceUsers S) FROM A.Contacts C) FROM Account A
I got this error through both my .Net debugger and through Eclipse.
 
UNKNOWN_EXCEPTION - An unexpected error occured. Please include this ErrorId if you contact support: 1444434015-196119
 
Here is the query I am running:
 
SELECT Name, AccountType__c, OwnerId, (SELECT id, ActivityDate from activityHistories WHERE ActivityType in ('Call - Inbound') ORDER BY ActivityDate DESC LIMIT 1) FROM Account WHERE OwnerId in ('00530000000eHt5AAE') AND AccountType__c in ('Prospect - Participating in Trial')
I am trying to get the last completed task on an account.  Is there a way I can query MAX(Task_date) or is there a query I can use that will get the last completed task on an account?
 
Thanks!
I was testing out some before and after triggers on cases.  When a case goes from a status that is not closed to a status that is closed it will not reflect this change in the trigger.  Basically Trigger.old.IsClosed will equal false (which would be correct) and Trigger.new.IsClosed is false as well (which I feel is incorrect).  I would expect that if the new status is a one that is a closed status Trigger.new.IsClosed would be true.
 
Any thoughts?
I am dealing with a lot of different types of fields including number (double and integer), Boolean, DateTime and Date fields.  How can I convert the exact value of these fields into friendly strings?
 
I am looking at the Apex Code Language Reference PDF, but I can't find anything in it.  Is there another more comprehensive Language Reference document some where?
 

This is really strange, say for example I have a variable that is a double named currentValue.  This line of code throws an error:

String test = currentValue;

ERROR:Severity and Description Path Resource Location Creation Time Id
Illegal assignment from Double to String MyTest_Support/Packages myPackage.apex line 22 1171636386867 61

But this line of code does not throw an error:

String test= '' + currentValue;

what am I missing?

I am dealing with a lot of different types of fields including number (double) and date fields.  How can I convert the exact value of these fields into strings?
 
I am looking at the Apex Code Language Reference PDF, but I can't find anything in it.  Is there another more comprehensive Language Reference document some where?
I am trying to write some trigger code and I need to access the field names of some of our custom fields.  I have a custom field named "Users" on the account level, and I want to create a string that contains the actual name of the field if it changed. However I don't know how to access a field's name (custom or otherwise).  I tried Trigger.new.Users__C.toLabel But this did not work.  Is this possible?
 
Here is my trigger code:
 

if (Trigger.old.Users__C != Trigger.new.Users__C)

{

String whatChanged = 'Changed '+ Trigger.new.Users__C.toLabel +' from '+ Trigger.old.Users__C + ' to ' + Trigger.new.Users__C;

}

 

Salesforce has history tracking for many objects but nothing for accounts that I can tell. 
 
It sounds like Apex will be able to help us here but is it the best solution?  Are their other ways to do this?
 
Our current business problem is history tracking on the account level, there are several extremely important fields and we need to know:
-When they changed
-Who changed them
-What value was before change
-What value is after change
 
We could create a custom object called "Account History" that could store all the relevant info. Using APEX can we create one of these "Account History" objects each time an account is Created\Updated\Saved?
 
We are going through an audit and our auditors want a see a way to track... well almost everything!
 
Can I do it using Apex?  Or should I do it some other way?
Is there anyway to do this?  The current way I am doing this is by Querying the contacts table for all the contactID's linked to an account.  Then I have to Query the cases table for all the cases that are link to the list of contactIDs.  Is there any easier way to simple get all the cases that are link to an account?
I am using C# and I am trying to create a new Event in SalesForce.  I have done this a bunch of time in VB.
 
The only date I am setting is the activity date\time like so:
 

myEvent.ActivityDateTime = DateTime.Now;

And it sets to a value like: {5/5/2006 5:17:51 PM}

When I try to do my create (the event is the only object in sfObjects) :

binding.create( sfObjects );

I get an exception, not a nice SalesForce returned error but an exception that goes to a catch block:

"System.Web.Services.Protocols.SoapHeaderException: '2006-05-05' is not a valid value for the type xsd:dateTime\r\n at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)\r\n at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)\r\n at sForce.SforceService.create(sObject[] sObjects) in c:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\Temporary ASP.NET Files\\idsforce\\03c6c53b\\b241ba34\\App_WebReferences.xsyiie8g.0.cs:line 449\r\n at sfFunct.sfCreate(sObject sfObject) in c:\\Inetpub\\wwwroot\\IDsForce\\App_Code\\sfFunct.cs:line 124"

Now if I don't set an ActivityDateTime I do not get an exception but I do get an error back from the API saying that ActivityDateTime is a required field

Anyone have any ideas?  The stupid thing is the exact same code worked fine in VB.NET!

I have a custom Picklist (Multi-Select) and when a run a report that groups by the Picklist it doesn't group by each item in the Picklist but each combination of selected items that exist.
 
For example pick list values are A,B,C.
 
My report groups will list all select combinations 
A
ABC
AC
B
BC
C
 
Instead I want my groups A, B C. 
 
If an item as all three selected it should show up in each group.  Any ideas on how to do this?

I want to loop through all the fields on an opportunity and if they are a multi select pick list, add their name to a list.  here is my non-working code:

 

        Schema.DescribeSObjectResult dsr = Opportunity.sObjectType.getDescribe();
        List<String>  MPL= new List<String>();
        for (Integer i=0; i < dsr.fields.Length; i++) {
                if( dsr.fields[i].getType == 'MultiPicklist'  )
                {
                    MPL.Items.Add( dsr.fields[i].getLabel  );
                }
            }

On the MPL.Items.Add( dsr.fields[i].getLabel  ) line I get the following error:

Error: Compile Error: Expression must be a list type: Schema.SObjectTypeFields at line 13 column 36 

 

From the documentation "getLabel" should return a string.  I don't know why it's asking for a list type. 

I have a custom Picklist (Multi-Select) and when a run a report that groups by the Picklist it doesn't group by each item in the Picklist but each combination of selected items that exist.
 
For example pick list values are A,B,C.
 
My report groups will list all select combinations 
A
ABC
AC
B
BC
C
 
Instead I want my groups A, B C. 
 
If an item as all three selected it should show up in each group.  Any ideas on how to do this?
I have an apex trigger that creates a new case and assigns it to a specific user.  What code would I use to tell Salesforce to send a notification email to the user?  In the Salesforce UI you can simply check off the "Send Notification Email" check box when assigning the case.
 
But my the page title comes out with a gray background (should be the same color as an account) and no icon! :robotmad:
 
Code:
<HTML>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<link href="/dCSS/Theme2/default/common.css" type="text/css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" >
<link href="/dCSS/Theme2/default/custom.css" type="text/css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" >
<BODY class=”account”>
<DIV class=bPageTitle>
 <DIV class="ptBody secondaryPalette">
 <DIV class=content><IMG class=pageTitleIcon alt=Entity_Name src="/s.gif">
 <H1 class=pageType>Account<SPAN class=titleSeparatingColon>:</SPAN></H1>
 <H2 class=pageDescription>Sign Up</H2>
 </DIV></DIV></DIV>

 All I did was cut and paste the code from the doc.  Anyone know what I am doing wrong?

 
I am trying to figure out a way to query my salesforce data for all opportunities that have less than 2 linked activities.  Anyone know how to do this?
What would you say is the average amount of time it takes you to develop an Apex trigger with its tests?
I am confused about the new Roll-up fields.  I would like to have an account field that gives me the total number of cases related to the account, can the new Roll-up fields do this?  If not how can I easily get this number on the account page?
I am trying to get the last completed task on an account.  Is there a way I can query MAX(Task_date) or is there a query I can use that will get the last completed task on an account?
 
Thanks!
I was testing out some before and after triggers on cases.  When a case goes from a status that is not closed to a status that is closed it will not reflect this change in the trigger.  Basically Trigger.old.IsClosed will equal false (which would be correct) and Trigger.new.IsClosed is false as well (which I feel is incorrect).  I would expect that if the new status is a one that is a closed status Trigger.new.IsClosed would be true.
 
Any thoughts?
I am dealing with a lot of different types of fields including number (double and integer), Boolean, DateTime and Date fields.  How can I convert the exact value of these fields into friendly strings?
 
I am looking at the Apex Code Language Reference PDF, but I can't find anything in it.  Is there another more comprehensive Language Reference document some where?
 

This is really strange, say for example I have a variable that is a double named currentValue.  This line of code throws an error:

String test = currentValue;

ERROR:Severity and Description Path Resource Location Creation Time Id
Illegal assignment from Double to String MyTest_Support/Packages myPackage.apex line 22 1171636386867 61

But this line of code does not throw an error:

String test= '' + currentValue;

what am I missing?

I am dealing with a lot of different types of fields including number (double) and date fields.  How can I convert the exact value of these fields into strings?
 
I am looking at the Apex Code Language Reference PDF, but I can't find anything in it.  Is there another more comprehensive Language Reference document some where?
Salesforce has history tracking for many objects but nothing for accounts that I can tell. 
 
It sounds like Apex will be able to help us here but is it the best solution?  Are their other ways to do this?
 
Our current business problem is history tracking on the account level, there are several extremely important fields and we need to know:
-When they changed
-Who changed them
-What value was before change
-What value is after change
 
We could create a custom object called "Account History" that could store all the relevant info. Using APEX can we create one of these "Account History" objects each time an account is Created\Updated\Saved?
 
We are going through an audit and our auditors want a see a way to track... well almost everything!
 
Can I do it using Apex?  Or should I do it some other way?
I am using C# and I am trying to create a new Event in SalesForce.  I have done this a bunch of time in VB.
 
The only date I am setting is the activity date\time like so:
 

myEvent.ActivityDateTime = DateTime.Now;

And it sets to a value like: {5/5/2006 5:17:51 PM}

When I try to do my create (the event is the only object in sfObjects) :

binding.create( sfObjects );

I get an exception, not a nice SalesForce returned error but an exception that goes to a catch block:

"System.Web.Services.Protocols.SoapHeaderException: '2006-05-05' is not a valid value for the type xsd:dateTime\r\n at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)\r\n at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)\r\n at sForce.SforceService.create(sObject[] sObjects) in c:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\Temporary ASP.NET Files\\idsforce\\03c6c53b\\b241ba34\\App_WebReferences.xsyiie8g.0.cs:line 449\r\n at sfFunct.sfCreate(sObject sfObject) in c:\\Inetpub\\wwwroot\\IDsForce\\App_Code\\sfFunct.cs:line 124"

Now if I don't set an ActivityDateTime I do not get an exception but I do get an error back from the API saying that ActivityDateTime is a required field

Anyone have any ideas?  The stupid thing is the exact same code worked fine in VB.NET!