• bakum
  • NEWBIE
  • 0 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 33
    Replies
    Hi, I've got a map(id, sObject).  I need to search the map to find all the rows where sObject.field=XXX, and then throw that sObject onto a list of sObjects for a DML operation later in the script.  I'm just at a loss how to do this.  Any suggestions?

It might be of some value to know that the map could contain 1000 rows and sObject.field=XXX could be true four or five times in the map.

-mb
  • October 29, 2008
  • Like
  • 0
Hi,

I've got two objects...Logistics_Event__c (LE__c) and Logistics_Event_Instructor__c(LEI__c).

LEI__c looks up LE__c, that is to say LEI__c is n:1 with LE__c.

I am writing a trigger on LE and testing for certain conditions.  When those conditions are met, I need to find all the associated LEI records and update a field (Update_Flags__c) on them.  This is my plan:

1)Create a set of all the LE__c's associated with the trigger.
    Set<Id> allLE = new Set<Id>();

    //create a set of all the Logistics_Events in the trigger
    for(Logistics_Event__c leTrigger:Trigger.new)
    {
      allLE.add(leTrigger.Id);
    }


2)Create a map of all the LEI__c's associated with those LE__c's.
    //use one query to find all the LEI's that are associated with the LE's in the trigger
    Map<Id, Logistics_Event_Instructor__c> leimap = new Map<Id,  Logistics_Event_Instructor__c>([SELECT lei.Id,lei.Event__c,lei.Update_Flags__c
                                FROM Logistics_Event_Instructor__c lei
                                WHERE Event__c in :allLe]);
(lei.Event__c is lookup to LE__c)

3)Using a for loop to iterate through the triggers do the testing

4)When testing finds a true value, search the map for all LEI's where Event__c = trigger.new[i].Id and add those LEI's to a list which will be updated in one DML operation.  This is where I start to lose the plot...

As I understand it my Map is an array where the key is the ID of LEI and the value is the actually LEI object itself.  If this were PHP I would simply loop through the array with foreach() and check the values in the object using object notation (i.e. objectname-->fieldname), but I don't understand how to do this in Apex.

QUESTIONS:
Is there a method that can search in the Value portion of the map for a certain field, if the value is an sObject? If there is, and if the return would be multiple rows in the map, how do I deal with them?

Or, is there a way to iterate through the map itself (cumbersome, I know) and then examine a field on the object?   It's probably some For loop syntax that is like Java 101 but I don't get it, and the Apex docs are certainly no help.

What about nested maps?  In PHP I can easily use multivariate arrays, and it seems nested maps are analagous, but the Apex docs don't include a shred of help in the syntax of using map methods with nested maps and it's not intuitive at all.  Maybe it is to someone else, I dunno...

Any other way anyone would suggest?

Thanks!
-mb
  • October 28, 2008
  • Like
  • 0
HI, I've got a workflow that is evaluating to false and I have no idea why.  Can you help?

OR (
          ISNULL(Guest_Name__r.Most_Recent_Reservation__c),
          Guest_Name__r.Most_Recent_Reservation__r.Departure_Date__c < Departure_Date__c
       )

Value(s) Found: Departure_Date__c=2008-11-11 00:00:00, Guest_Name__r.Most_Recent_Reservation__c=null, Guest_Name__r.Most_Recent_Reservation__r.Departure_Date__c=null

Criteria evaluates to false?!?!?

Substitute the Values Found in the formula and get this:
OR (
          ISNULL(null),
          null < 2008-11-11 00:00:00
      )

Why isn't this evaluating to true!?!?!

Thanks,
-mb
  • October 24, 2008
  • Like
  • 0
Hi,

Background: Customer is a travel agency.  They have a custom object called Reservation__c, and on that object are two fields, Guest_Name__c (lookup to Account), and Departure_Date__c (date).

They want to be able to report on the accounts that have not booked a reservation within the last six months.  I cannot get this with a straight report, so I had the bright idea to put a field on the Account called Most_Recent_Reservation__c (lookup to Reservation__c), and a workflow on Reservation__c.  When a Reservation__c is created or edited a workflow compares Reservation.Departure_Date__c and Account.Most_Recent_Reservation__r.Departure_Date__c and applies some logic to update Account.Most_Recent_Reservation__c with that Reservation ID or not.  The customer could then report off the Most_Recent_Reservation__c.Departure_Date__c and Bob's my Uncle.  The logic for when to update works.  The first problem is I can't do a cross object update with a workflow. 

So my second bright idea is to use the workflow to set a flag on Reservation__c, and trap for that flag with a trigger.  The trigger can then do the cross object update no problem.

The second problem is I've done this sort of thing before and run into governor limits when doing bulk updates. 

So, the question is can I write this trigger some way so as not to hit the governor limit?  Here's the trigger code:

trigger update_most_recent_reservation on Reservation__c (after insert, after update)
{
    //make it bulk safe
    for (Integer i=0; i<Trigger.new.size(); i++)
    {
        Reservation__c res = Trigger.new[i];
        //check to see if the update flag is set to true
        if (res.Update_Guest_Most_Recnt_Resrvation_Flag__c)
        {
            //double check that it's appropriate to update the field
            if (res.Guest_Name__c != null && res.Departure_Date__c != null)
            {
                //find the right account to update and update it
                Account guest = [select Id from Account where Id = :res.Guest_Name__c];
                guest.Most_Recent_Reservation__c = res.Id;
                update guest;
            }
        }   
        //set the update flag on Reservation__c back to false
        res.Update_Guest_Most_Recnt_Resrvation_Flag__c = FALSE;
        update res;
    }
}

  • October 23, 2008
  • Like
  • 0
Hi,

I'm a consultant with a client that needs to use the data loader on Mac.  I see references on the boards but I can't find links to specific Mac installs for data loader.  Docs too. 

Can someone point me in the right direction?  Thanks!

-mb
  • September 18, 2008
  • Like
  • 0
Hi,

I'm a consulting and I just had an initial meeting with a client whose business is structured such that their accounts all have related "locations", and each opportunity product will require specific information for each location related to that account.

E.G. They might work with Home Depot, and Home Depot might buy something for every store they have, but the exact details of what each store gets are up to the store themselves and it all needs to be logged in salesforce associated to that opporutnity.

THE ISSUE HERE is that some of their customers have five figures of locations.  The biggest count is 40K.  This means if not only does that account need 40K related locations records, but if that account buys something the opportunity products will need 40K location_options records, upon which they will run reports for work orders, shipping, sales reports, and whatnot.

MY QUESTION is I've never worked with data structured like that in SF before.  Not even thinking about data structure issues, just thinking about UI alone, trying to enter in 40K optional records would take literally days of work (5 seconds per record entry = 200K seconds = 55.5 hours).  So there's definitely a need for some kind of custom UI.

But beyond that, what kinds of data consdierations do I have?  Like I say, I've not worked with SF before on that scale.  (actually, I don't think I've ever done a project with those kinds of numbers).  Are there things I need to be thinking about when I create these objects.  I can't help but wonder if SF is the right application for them...

-mb
  • August 26, 2008
  • Like
  • 0
Hi,

BACKGROUND
I have an approval process on object Marketing_Project__c.  When that approval process ends (either rejected or accepted) I am sending an email to a list of people from a related object.  The way I'm doing this is having the approval update a flag field on the Marketing_Project__c object, and then using a trigger to check for a change to that flag field, and send the emails as needed.  Then the trigger updates the fields back to false.

HERE'S MY QUESTIONS
1) If there's an exception in the trigger will that roll back the approval?
2) If I catch an exception to the field update (at the end of the trigger) what do I do with it?  DO I tell the user?  If so, how?  Trigger.New...that's the field update...not the approval process.  I'm wondering if maybe I should let the exception through to halt the process and get some messaging to me as the sys admin. 

What do you think?
  • August 13, 2008
  • Like
  • 0
Hi, I am trying to make a VF page to replace something I did pretty easily with s-controls. 

Basically, I have an object, System_Engineer__c which a related object (1:n) Support_Time__c.  The Support_Time__c records have an Approved__c field (checkbox).

What I want to do is display a list of the unapproved support time records on the System_Engineer's detail page, and then provide a link to approve each record.  Eventually, I'd like to have checkboxes next to each unapproved record, one Submit button at the bottom, and then the controller updates the APproved__c field for every checked record, but that's getting ahead of myself.  Right now, clicking an [ approve ] link should simply update the single record in question.  But it doesn't work.  It seems to be passing the ID of the SYstem_Engineer himself, instead of the ID of the Support_Time record.  I don't know why.

Any help?

Thanks! 

-mb


<apex:page controller="MyController" tabStyle="Sales_Engineer__c">
    <apex:detail relatedList="false" />
   <apex:form >
    <apex:pageBlock title="My Unapproved Support Times">
     <apex:dataTable id="timesTable" value="{!myUnapprovedTimes}" var="aTime" width="50%" >
         <apex:column ><apex:facet name="header"><b>Date</b></apex:facet>{!aTime.Date__c}</apex:column>
         <apex:column ><apex:facet name="header"><b>Hours</b></apex:facet>{!aTime.Hours__c}</apex:column>
         <apex:column ><apex:facet name="header"><b>Approve All</b></apex:facet>
             <apex:commandLink action="{!approveMe}" value="[ approve ]" reRender="timesTable">
               <apex:param value="{!aTime.Id}" assignTo="{!myId}"></apex:param>
            </apex:commandLink>
         </apex:column> 
        
      </apex:dataTable> 
    </apex:pageBlock>
  </apex:form>

</apex:page>
~~~~~~~~~~~~~~~~
public class MyController {

    Id myId;

    public void setMyId(Id id)
    {
     myId = id;
    }

  
    public String getMyId() {
      return myId;
    }  


   public List<Support_Time__c> getMyUnapprovedTimes()
    {
        return [SELECT Id, Date__c, Hours__c, Approved__c FROM Support_Time__c
                WHERE Sales_Engineer__c = :System.currentPageReference().getParameters().get('id')
                AND Approved__c = FALSE
                ORDER BY Date__C DESC];
    }
   
   public PageReference approveMe() {
       Support_Time__c st = [SELECT Id, Name FROM Support_Time__C WHERE Id=:myId];
       st.Approved__c = TRUE;
       update st;
       return null;
   }
 
}

  • August 08, 2008
  • Like
  • 0
Hi,

I'm running a very simple query and getting an "Unknown runtime error" in response.  Never got one of those before.  Anyone know what it's about or how I go about making it stop?

Here's the complete code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Support Times</title>
<!-- Include the Salesforce style sheets -->
<link href="/sCSS/Theme2/en/common.css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" type="text/css" />
<link href="/sCSS/10.0/Theme2/allCustom.css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" type="text/css" />

<style></style>

<!-- Get the AJAX Toolkit -->
<script language="JavaScript1.2" src="/js/functions.js"></script>
<script src="/soap/ajax/11.1/connection.js" type="text/javascript"></script>

<script id="clientEventHandlersJS" language="javascript">

    function failure(error)
    {
        var msgarea = document.getElementById("msgarea");
        msgarea.innerHTML += "Error retrieving Support Times info";
        msgarea.innerHTML += "<br>API Error: " + error.description;
        msgarea.innerHTML += "<br><br>Fault code: " + error.faultcode;
        msgarea.innerHTML += "<br><br>Fault string: " + error.faultstring;       
    }

    function initPage()
    {
   
        var msgarea = document.getElementById("msgarea");
   
        if ('{!$UserRole.Name}' != 'System Administrator')
        {
            msgarea.innerHTML = "We're sorry, but this button is under consturction and only for use by System administrators at the present time.  You will be returned to the previous screen.";
            window.location.href = "/{!Support_Time__c.Id}";
        }
        else
        {
            try
            {
                var myquery = "SELECT Engineer_Name__c, Date__c, Hours__c, Approved__c FROM Support_Time__c";
           
                // msgarea.innerHTML =    myquery+ '<br><br>';
                sforce.connection.query(myquery,{onSuccess :success,
                                                 onFailure:failure,
                                                 source : {output : msgarea,
                                                           startTime : new Date().getTime()
                                                          }
                                                }
                                       );       
       
            }
            catch (error)
            {
                msgarea.innerHTML += "EXCEPTION";
                msgarea.innerHTML += "<br>API Error: " + error.description;
                msgarea.innerHTML += "<br><br>Fault code: " + error.faultcode;
                msgarea.innerHTML += "<br><br>Fault string: " + error.faultstring;
            }
   
        }
    }


function success(queryResult)
{
    var msgarea = document.getElementById("msgarea");
    var outputarea = document.getElementById("outputarea");   

    if (queryResult.size > 0)
     {
         //get the records array
        var records = queryResult.getArray('records');
        var date = "";
        var hours = "";
        var approved = "";
        var output = "";
        var name= "";
        
         for (var i=0; i< records.length; i++)
         {
           date = records[i].Date__c;
           hours = records[i].Hours__c;
           approved = records[i].Approved__c;
           name = records[i].Engineer_Name__c;
           output += "<tr><td>"+name+"</td><td>"+date+"</td><td>"+hours+"</td><td>"+approved+"</td></tr>";
         }

    }
    else
    {
     output += "<tr><td>No Support Times found for {!Support_Time__c.Engineer_Name__c}</td></tr>";
    }

       outputarea.innerHTML = output;

}

</script>

</head>


<body onload="initPage()" class="Support_Times__c detailPage">
<DIV class=bPageTitle>
     <DIV class="ptBody secondaryPalette">
     <DIV class=content><IMG class=pageTitleIcon alt=Entity_Name src="/s.gif">
     <H1 class=pageType>Approve Multiple Support Time entries at once<SPAN class=titleSeparatingColon>:</SPAN></H1>
     <H2 class=pageDescription>Under Construction</H2>
 </DIV>
</DIV>
</DIV>
<DIV class="bPageBlock secondaryPalette">
 <DIV class=pbBody>
 <DIV class='pbSubsection' id='msgarea'>
 </DIV>
</DIV>
</DIV>

<table id="outputarea"></table>


</body>
</html>

  • August 01, 2008
  • Like
  • 0
Hi,

I have a custom object, Logistics_Event__c, which has a field which is a lookup to another custom object, Course__c. (I'm doing this with the PHP toolkit, by the way)

I want to query my Logistics Events and return fields from Course__c: Name and Version__c.

I've tried two ways with no luck:
SELECT
            l.Id,
            l.Start_Date__c,
            l.Number_of_Days__c,
            l.Location__c,
            Course__r.Name,
            Course__r.Version__c
            FROM Logistics_Event__c l

Gives me no error, but doesn't return any info.  There is not ALWAYS a course ID on the Logistics_Event__c record, but there is about 50% of the time.  I would have thought it would return nothing sometimes and the field data when there's data to return.

I also tried this way:
SELECT
            l.Id,
            l.Start_Date__c,
            l.Number_of_Days__c,
            l.Location__c,
            (SELECT Name, Version__c FROM Course__c)
            FROM Logistics_Event__c l

ERROR: Didn't understand relationship 'Course__c' in FROM part of query call

Can someone illuminate me?

Thanks!

-mb
  • July 22, 2008
  • Like
  • 0
Hi,

I have a custom object, Logistics_Event__c, which has a field which is a lookup to another custom object, Course__c. (I'm doing this with the PHP toolkit, by the way)

I want to query my Logistics Events and return fields from Course__c: Name and Version__c.

I've tried two ways with no luck:
SELECT
            l.Id,
            l.Start_Date__c,
            l.Number_of_Days__c,
            l.Location__c,
            Course__r.Name,
            Course__r.Version__c
            FROM Logistics_Event__c l

Gives me no error, but doesn't return any info.  There is not ALWAYS a course ID on the Logistics_Event__c record, but there is about 50% of the time.  I would have thought it would return nothing sometimes and the field data when there's data to return.

I also tried this way:
SELECT
            l.Id,
            l.Start_Date__c,
            l.Number_of_Days__c,
            l.Location__c,
            (SELECT Name, Version__c FROM Course__c)
            FROM Logistics_Event__c l

ERROR: Didn't understand relationship 'Course__c' in FROM part of query call

Can someone illuminate me?

Thanks!

-mb

  • July 21, 2008
  • Like
  • 0
Hi, I'm getting a persistent INVALID_LOGIN problem...

I am 100% sure the username and password are right.  I cut and paste them into the web login and that worked. 
The wsdl is a fresh download from this morning and it is accessible in that spot.



here's the code.  it's just a little POC for connecting to SF via PHP api and nothing is doing yet:

ini_set("soap.wsdl_cache_enabled", "0");
require_once (DIR_FS_SF_SOAP_CLIENT.'SforceEnterpriseClient.php');
require_once (DIR_FS_SF_SOAP_CLIENT.'SforceHeaderOptions.php');

try
{

   
    $mySforceConnection = new SforceEnterpriseClient ();
    $mySoapClient = $mySforceConnection->createConnection(DIR_FS_SF_SOAP_CLIENT."enterprise.wsdl.xml");
    $mylogin = $mySforceConnection->login("XXX", "YYY");

      $userResult = $mylogin->userInfo;
      print_r($userResult);
      echo $userResult->userFullName.', your session id is '.$mylogin->sessionId;

      $query = 'SELECT * FROM Opportunity';
      $response = $mySforceConnection->query(($query));

      print_r($response);

      foreach ($response->records as $record)
      {
       print_r($record);
      }

      print_r($mySforceConnection->getLastRequest());

      $bagent = $_SERVER["HTTP_USER_AGENT"];
      echo '<b>USER AGENT:</b> '.$bagent.'<br><br>';

}
catch (Exception $e)
{
  echo $e->faultstring;
}
  • November 08, 2007
  • Like
  • 0
Hi, I've never written a unit test class before and I'm trying to deploy my first trigger.  The trigger itself works fine, the class I wrote to test the trigger works fine, but when I try to deploy Eclipse tells me I have no test coverage on my trigger!  Not true!  Hopefully I'm doing something stupid.

The background details...we have custom fields for Total Costs on our Opportunities and Line Items, so we can calculate margins and markups and such and make sure our salespeople are doing a good job.  The trigger is supposed to do this:
-whenever a line item is created, updated, or deleted
-find the opportunityID of the line item.
-run through every line items attached to that oportunity.
-total all the Total Costs fields on those line items, and shove that total in Total_Costs_Apex__c on the opportunity itself.

The code works fine.  I just can't deploy.

Here's the code:

trigger update_opportunity_costs on OpportunityLineItem (after delete, after insert, after update)
{
    double totalCost = 0.00;
   
    for (OpportunityLineItem oli : Trigger.new)
    {   
         //grab info on every line item attached to the opportunity from the triggering line item.
         for (OpportunityLineItem myOles : [SELECT Total_Costs__c FROM OpportunityLineItem WHERE OpportunityID=:oli.OpportunityId])
         {
          //total the costs of these line items
          totalCost += myOles.Total_Costs__c;
         }
         Opportunity oppty = new Opportunity(Id=oli.OpportunityId);
         //update the opportunity Total Costs Apex field with the total costs of all line items.
         oppty.Total_Costs_Apex__c = totalCost;
         //update the opportunity
         update oppty;  
    }
   
}

~~~~~~
and here's the unit test class I wrote:
public class opportunity_costs_update_test {

    static testMethod void myTest()
    {
   
      Pricebook2 stdPb = [select Id from Pricebook2 where name='Standard' limit 1];   
      PricebookEntry pbe = [select p.Id From PricebookEntry p where p.Name = 'SLA: Silver' and p.Pricebook2Id = :stdPb.Id];

      Opportunity oppty = new Opportunity();
      oppty.name = 'Unit Test Opportunity.';
      oppty.ForecastCategory = 'Pipeline';
      oppty.CloseDate = Date.newInstance(2020,10,10);
      oppty.StageName = 'Proposal/Price Quote';
      oppty.CurrencyIsoCode = 'USD';
      oppty.Pricebook2ID = stdPb.Id;
      insert oppty;
       
      OpportunityLineItem oli = new OpportunityLineItem();
      oli.OpportunityId = oppty.Id;
      oli.Costs_Other__c = 32000.00;
      oli.TotalPrice = 70000.00;
      oli.Quantity = 2;
      oli.PricebookEntryId = pbe.Id;
      insert oli;
    }
}

Any help?  Thanks in advance!
  • November 07, 2007
  • Like
  • 0
Hi, I want to override the Submit for Approval button...where the heck is it??  it's not on the opportunity.  Where is it?  Setup>>Customize>>???

Also, any hints on how not to override it completely, just want to insert a little ajax like a trigger that will run through the line items and do some wizardy on them and set some fields in a certain way when that button is hit.  I'm thinking this is the process I would run through, what do you think?

-overridden button is pressed
-run api calls to do the changes on the line items as needed
-run api call to submit opportunity for approval
-reload page to same location as you would get to after pressing the standard Submit for Aproval button.

Thanks!

-mb
  • September 20, 2007
  • Like
  • 0
Hi, I'm trying to play with approvals through the api and only found documentation of the approval object which is stated to apply only to contracts.  We are approving opportunities.  Where in the api docs does it talk about the approval process for non-contracts?

thanks!

-mb
  • September 13, 2007
  • Like
  • 0
Hi, I have a scenario I'd like to run by someone because I'm a bit confused and would rather not run down the wrong path...

Let's say I'm building an app to schedule classes.  So there's custom objects for Courses (which have a title, description, and number of days duration) and then Classes, which are scheduled courses, and which contain a lookup to the Course.  I'd like there to be a field in the CLASS object that allows the user to set a duration for the individual class, in case it is different than the standard (say they client wants to run a 3 day course in 2 days which happens a lot). 

What I'd like is that when the user completes the lookup form to choose the course that is to be scheduled, I'd like the duration field on the class form to be updated with what is set for that course in the course object. But then the user could over-write that if they wanted. 

Out in non-salesforce land I'd just throw a javascript "onchange" or something on the course field and then do a little ajax magic an voila.  But I'm not sure here how to get the onchange to happen.  Doesn't seem like it's apex code cause they supposedly doesn't let me opdate the UI.  But is it an s-control?  I dunno. 

Any help would be greatly appreciated.
  • August 29, 2007
  • Like
  • 0
Hi, folks.  Can someone please point me to the document that outlines the AJAX tools in use by Salesforce to the level of, here's the objects we are creating for you and their methods and functions, here's the list of javascript functions we've created and the syntax on how to use them?

An example of what I'm looking for is the sforce object.  It's obviously got standard methods and functions like sforce.SObject, I can see that much from the sample code.  But I'll be goll danged if I can find where this is all outlined and documented.  Am I just supposed to guess?

Also, I have already seen the AJAX Toolkit Developer's Guide and that's not it. 

Another thing I'd love to see documented are the standard javascript tools in /js/functions.js.  I just can't find that anywhere. 

It feels like I'm working on an early version of an open source platform, only we're paying for this one.  Which is strange. 
  • August 09, 2007
  • Like
  • 0
Hi, I'm a PHP developer tasked with creating an app for Salesforce.  I've got my work cut out for me. 

First off, I'm going through the language reference and the quick start in particular but there's a problem.  Page 15 hsa instructions for creating my first Apex code program, but it causes an error: "Error: Compile Error: expecting "package", found 'global' at line 1 column 1"

Any help here?

Secondly, I am on my own trying to cobble together an application and it's going OK.  I have a field which is a lookup-relationship with the User object.  I want the choices in that field to be restricted to a subset of users, and I am just not sure where to begin to do this sort of thing.  I'd also like to have a multi-select field related to the User object, in the same way (i.e. a subset of the user object).

If someone can point me in the write direction (like, oh, just write an s-control or put a trigger on it or whatever) I will go through the docs until I figure it out.  I'm just not sure where to start!

thanks,
MB
  • July 31, 2007
  • Like
  • 0
Hi, I'm brand new to Apex and I've got a few questions that hopefully aren't too newbie.

1)Is there a reference material for the native platform beyond that nice PDF "Crating Native Applications...?"  I didn't find one but one can always hope.

2)Lookup fields, restricting values - I want to create a lookup field that is related to the Users object but only presents a certain subset of users for selection.  Is this done through roles or something? 

3)multi-select lookup fields - I need to create lookup fields that allow multi-select values.  Is this an s-control snippet?  Seems like I should be able to make something like this myself if I had to, but I'm not even sure where to begin/what direction to go in.

Any advice here would be greatly apprieciated.  Not looking for hand holding, just general direction pointing.

Thanks!
-mb
  • July 20, 2007
  • Like
  • 0
    Hi, I've got a map(id, sObject).  I need to search the map to find all the rows where sObject.field=XXX, and then throw that sObject onto a list of sObjects for a DML operation later in the script.  I'm just at a loss how to do this.  Any suggestions?

It might be of some value to know that the map could contain 1000 rows and sObject.field=XXX could be true four or five times in the map.

-mb
  • October 29, 2008
  • Like
  • 0
HI, I've got a workflow that is evaluating to false and I have no idea why.  Can you help?

OR (
          ISNULL(Guest_Name__r.Most_Recent_Reservation__c),
          Guest_Name__r.Most_Recent_Reservation__r.Departure_Date__c < Departure_Date__c
       )

Value(s) Found: Departure_Date__c=2008-11-11 00:00:00, Guest_Name__r.Most_Recent_Reservation__c=null, Guest_Name__r.Most_Recent_Reservation__r.Departure_Date__c=null

Criteria evaluates to false?!?!?

Substitute the Values Found in the formula and get this:
OR (
          ISNULL(null),
          null < 2008-11-11 00:00:00
      )

Why isn't this evaluating to true!?!?!

Thanks,
-mb
  • October 24, 2008
  • Like
  • 0
Hello,
 
I've created an s-control and in it is a very plain web page (at least currently) and some text.  Below that is a link that users can click on and it should bring them to another page and supply some login info for them.  It seemed to be working and I tweaked it a little bit and now it is appending additional info to the link  - the following info
 
https://na3.salesforce.com/servlet/servlet and then my link but encased in quotes.  The site that I'm directing the users to is completely outside of salesforce and according to the help which uses a google link this shouldn't be a problem.  Why am I being redirected inside of Salesforce?  Any help is much appreciated!
 
The other issue I seem to be running into is that when it does appear to partially work the pieces of the link don't seem to getting passed through.  I've tested the link in a stand alone page from my desktop and it works fine from there so the code itself is good but is there something else I should be doing?  Or a way around using s-controls that might make this easier?
 
Thanks!
 


Message Edited by ReneeL on 10-24-2008 07:51 AM
  • October 24, 2008
  • Like
  • 0
hi
 
is it possible to save Picklist values in a Look Up Field?
 
I want to save multiple (picklist) values in a LoopUp field.
hi
 
i want to refer multiple objects of same object type in another object record.
 
My requirement is:
 
i want to save multiple invoices in Invoice Field in Payment Object. can u please help me how to save multiple values in a single field.
 
User can select multiple invoices and to be saved in Invoice field in Payment object. in payment object invoice field is the Look up field.
Hi,

Background: Customer is a travel agency.  They have a custom object called Reservation__c, and on that object are two fields, Guest_Name__c (lookup to Account), and Departure_Date__c (date).

They want to be able to report on the accounts that have not booked a reservation within the last six months.  I cannot get this with a straight report, so I had the bright idea to put a field on the Account called Most_Recent_Reservation__c (lookup to Reservation__c), and a workflow on Reservation__c.  When a Reservation__c is created or edited a workflow compares Reservation.Departure_Date__c and Account.Most_Recent_Reservation__r.Departure_Date__c and applies some logic to update Account.Most_Recent_Reservation__c with that Reservation ID or not.  The customer could then report off the Most_Recent_Reservation__c.Departure_Date__c and Bob's my Uncle.  The logic for when to update works.  The first problem is I can't do a cross object update with a workflow. 

So my second bright idea is to use the workflow to set a flag on Reservation__c, and trap for that flag with a trigger.  The trigger can then do the cross object update no problem.

The second problem is I've done this sort of thing before and run into governor limits when doing bulk updates. 

So, the question is can I write this trigger some way so as not to hit the governor limit?  Here's the trigger code:

trigger update_most_recent_reservation on Reservation__c (after insert, after update)
{
    //make it bulk safe
    for (Integer i=0; i<Trigger.new.size(); i++)
    {
        Reservation__c res = Trigger.new[i];
        //check to see if the update flag is set to true
        if (res.Update_Guest_Most_Recnt_Resrvation_Flag__c)
        {
            //double check that it's appropriate to update the field
            if (res.Guest_Name__c != null && res.Departure_Date__c != null)
            {
                //find the right account to update and update it
                Account guest = [select Id from Account where Id = :res.Guest_Name__c];
                guest.Most_Recent_Reservation__c = res.Id;
                update guest;
            }
        }   
        //set the update flag on Reservation__c back to false
        res.Update_Guest_Most_Recnt_Resrvation_Flag__c = FALSE;
        update res;
    }
}

  • October 23, 2008
  • Like
  • 0
Is there a way to create multiple custom fields on a campaign (customer 1, 2, 3, etc) and have each of them post to a campaign related list on an account?
I am trying to use a custom s-control to take the data from an existing lead, and create a new ‘candidate’ (a custom object) - for those people that fill out a form online, but are looking for a job, not our services.  I am able to have the custom s-control open up the ‘new candidate’ window, but I can’t get any of the data to populate.  What am I doing wrong?  How do I make it so that sfdc knows to pull the data from the lead record?

I currently have:

{!URLFOR($Action.Candidate__c.New)},%{!Candidate__c.Name}={!Lead.FirstName}

Any help would be greatly appreciated!

  • October 22, 2008
  • Like
  • 0
Hi, I am trying to make a VF page to replace something I did pretty easily with s-controls. 

Basically, I have an object, System_Engineer__c which a related object (1:n) Support_Time__c.  The Support_Time__c records have an Approved__c field (checkbox).

What I want to do is display a list of the unapproved support time records on the System_Engineer's detail page, and then provide a link to approve each record.  Eventually, I'd like to have checkboxes next to each unapproved record, one Submit button at the bottom, and then the controller updates the APproved__c field for every checked record, but that's getting ahead of myself.  Right now, clicking an [ approve ] link should simply update the single record in question.  But it doesn't work.  It seems to be passing the ID of the SYstem_Engineer himself, instead of the ID of the Support_Time record.  I don't know why.

Any help?

Thanks! 

-mb


<apex:page controller="MyController" tabStyle="Sales_Engineer__c">
    <apex:detail relatedList="false" />
   <apex:form >
    <apex:pageBlock title="My Unapproved Support Times">
     <apex:dataTable id="timesTable" value="{!myUnapprovedTimes}" var="aTime" width="50%" >
         <apex:column ><apex:facet name="header"><b>Date</b></apex:facet>{!aTime.Date__c}</apex:column>
         <apex:column ><apex:facet name="header"><b>Hours</b></apex:facet>{!aTime.Hours__c}</apex:column>
         <apex:column ><apex:facet name="header"><b>Approve All</b></apex:facet>
             <apex:commandLink action="{!approveMe}" value="[ approve ]" reRender="timesTable">
               <apex:param value="{!aTime.Id}" assignTo="{!myId}"></apex:param>
            </apex:commandLink>
         </apex:column> 
        
      </apex:dataTable> 
    </apex:pageBlock>
  </apex:form>

</apex:page>
~~~~~~~~~~~~~~~~
public class MyController {

    Id myId;

    public void setMyId(Id id)
    {
     myId = id;
    }

  
    public String getMyId() {
      return myId;
    }  


   public List<Support_Time__c> getMyUnapprovedTimes()
    {
        return [SELECT Id, Date__c, Hours__c, Approved__c FROM Support_Time__c
                WHERE Sales_Engineer__c = :System.currentPageReference().getParameters().get('id')
                AND Approved__c = FALSE
                ORDER BY Date__C DESC];
    }
   
   public PageReference approveMe() {
       Support_Time__c st = [SELECT Id, Name FROM Support_Time__C WHERE Id=:myId];
       st.Approved__c = TRUE;
       update st;
       return null;
   }
 
}

  • August 08, 2008
  • Like
  • 0
Hi,

I'm running a very simple query and getting an "Unknown runtime error" in response.  Never got one of those before.  Anyone know what it's about or how I go about making it stop?

Here's the complete code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Support Times</title>
<!-- Include the Salesforce style sheets -->
<link href="/sCSS/Theme2/en/common.css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" type="text/css" />
<link href="/sCSS/10.0/Theme2/allCustom.css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" type="text/css" />

<style></style>

<!-- Get the AJAX Toolkit -->
<script language="JavaScript1.2" src="/js/functions.js"></script>
<script src="/soap/ajax/11.1/connection.js" type="text/javascript"></script>

<script id="clientEventHandlersJS" language="javascript">

    function failure(error)
    {
        var msgarea = document.getElementById("msgarea");
        msgarea.innerHTML += "Error retrieving Support Times info";
        msgarea.innerHTML += "<br>API Error: " + error.description;
        msgarea.innerHTML += "<br><br>Fault code: " + error.faultcode;
        msgarea.innerHTML += "<br><br>Fault string: " + error.faultstring;       
    }

    function initPage()
    {
   
        var msgarea = document.getElementById("msgarea");
   
        if ('{!$UserRole.Name}' != 'System Administrator')
        {
            msgarea.innerHTML = "We're sorry, but this button is under consturction and only for use by System administrators at the present time.  You will be returned to the previous screen.";
            window.location.href = "/{!Support_Time__c.Id}";
        }
        else
        {
            try
            {
                var myquery = "SELECT Engineer_Name__c, Date__c, Hours__c, Approved__c FROM Support_Time__c";
           
                // msgarea.innerHTML =    myquery+ '<br><br>';
                sforce.connection.query(myquery,{onSuccess :success,
                                                 onFailure:failure,
                                                 source : {output : msgarea,
                                                           startTime : new Date().getTime()
                                                          }
                                                }
                                       );       
       
            }
            catch (error)
            {
                msgarea.innerHTML += "EXCEPTION";
                msgarea.innerHTML += "<br>API Error: " + error.description;
                msgarea.innerHTML += "<br><br>Fault code: " + error.faultcode;
                msgarea.innerHTML += "<br><br>Fault string: " + error.faultstring;
            }
   
        }
    }


function success(queryResult)
{
    var msgarea = document.getElementById("msgarea");
    var outputarea = document.getElementById("outputarea");   

    if (queryResult.size > 0)
     {
         //get the records array
        var records = queryResult.getArray('records');
        var date = "";
        var hours = "";
        var approved = "";
        var output = "";
        var name= "";
        
         for (var i=0; i< records.length; i++)
         {
           date = records[i].Date__c;
           hours = records[i].Hours__c;
           approved = records[i].Approved__c;
           name = records[i].Engineer_Name__c;
           output += "<tr><td>"+name+"</td><td>"+date+"</td><td>"+hours+"</td><td>"+approved+"</td></tr>";
         }

    }
    else
    {
     output += "<tr><td>No Support Times found for {!Support_Time__c.Engineer_Name__c}</td></tr>";
    }

       outputarea.innerHTML = output;

}

</script>

</head>


<body onload="initPage()" class="Support_Times__c detailPage">
<DIV class=bPageTitle>
     <DIV class="ptBody secondaryPalette">
     <DIV class=content><IMG class=pageTitleIcon alt=Entity_Name src="/s.gif">
     <H1 class=pageType>Approve Multiple Support Time entries at once<SPAN class=titleSeparatingColon>:</SPAN></H1>
     <H2 class=pageDescription>Under Construction</H2>
 </DIV>
</DIV>
</DIV>
<DIV class="bPageBlock secondaryPalette">
 <DIV class=pbBody>
 <DIV class='pbSubsection' id='msgarea'>
 </DIV>
</DIV>
</DIV>

<table id="outputarea"></table>


</body>
</html>

  • August 01, 2008
  • Like
  • 0
Hi,

I have a custom object, Logistics_Event__c, which has a field which is a lookup to another custom object, Course__c. (I'm doing this with the PHP toolkit, by the way)

I want to query my Logistics Events and return fields from Course__c: Name and Version__c.

I've tried two ways with no luck:
SELECT
            l.Id,
            l.Start_Date__c,
            l.Number_of_Days__c,
            l.Location__c,
            Course__r.Name,
            Course__r.Version__c
            FROM Logistics_Event__c l

Gives me no error, but doesn't return any info.  There is not ALWAYS a course ID on the Logistics_Event__c record, but there is about 50% of the time.  I would have thought it would return nothing sometimes and the field data when there's data to return.

I also tried this way:
SELECT
            l.Id,
            l.Start_Date__c,
            l.Number_of_Days__c,
            l.Location__c,
            (SELECT Name, Version__c FROM Course__c)
            FROM Logistics_Event__c l

ERROR: Didn't understand relationship 'Course__c' in FROM part of query call

Can someone illuminate me?

Thanks!

-mb
  • July 22, 2008
  • Like
  • 0