• dizzyem
  • NEWBIE
  • 90 Points
  • Member since 2011

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 27
    Replies

I am attempting to compare the dates from a job schedule to dates from it's child assignment schedules so I can determine which dates have not yet been assigned. So far I have a list of both jobdates and assignmentdates. My initial thought was to convert those to sets and do a minusSet to determine which dates are left. However, I am having trouble converting my date list to a set. I am getting an error that says:  Invalid initial value type LIST<Date__c> for SET<Date>

 

Here is my code for converting my job date list to a job date set:

 

 private List<Date__c> jobdates{ get {
        if(jobdates == null){
            jobdates = new list<Date__c>();
            jobdates = [select date__c, id from date__c where time_frame__c = :jobtimeframe];
        }
        return jobdates;
    } set;}
 
        private set<Date> setjobdates{ get {
        if(setjobdates == null){
            for(Date__c d : jobdates){
                setjobdates.add(d.date__c);
            }
        }
        return setjobdates;
    } set; }

 

Now, I am wondering if there is an easy fix to this or if there is another way to simply compare my two lists (jobdates and assignmentdates) without converting them to a set?

Wondering if anybody can help me with this one...

 

I have a custom button on the detail page to approve a record (which just sets an Outcome field to "Approved"). Then I have a trigger that will update all of the other options to "Rejected". The first time I approve an option record it works perfectly. That record's outcome is set to "Approved" and all of the other option records' outcomes are set to "Rejected". However, if I then go in to one of those rejected options and click the Approve button, the outcome is set to "Approved" as it should be but none of the other options' outcomes are changed to be set to "Rejected". Let me know if you have any thoughts...

 

Here is my button:

 

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")} 

alert ("Your Housing Option has been Approved. Thanks."); 

var newRecords = []; 

var c = new sforce.SObject("Housing_Options__c"); 
c.id ="{!Housing_Options__c.Id}"; 
c.Outcome__c = "Approved"; 
newRecords.push(c); 

result = sforce.connection.update(newRecords); 

window.location.reload();

 

 

Here is my trigger:

 

trigger setOutcomes on Housing_Options__c (after update) 
{
  List<ID> requestIDs = new List<ID>();
  Boolean needsUpdate = FALSE; 
    for (Housing_Options__c option: trigger.new)
    {
    requestIDs.add(option.Housing_Request__c);
    }
    List<Housing_Options__c> otheroptions = new List<Housing_Options__c>([select id, Outcome__c, Housing_Request__c from Housing_Options__c where Housing_Request__c in: requestIDs]);
    for (Housing_Options__c option: trigger.new)
    {
    for (integer i=1; i < otheroptions.size(); i++)
     {
        if ( ((Trigger.isInsert) ||       (Trigger.isUpdate) && (Trigger.oldMap.get(option.id).Outcome__c != 'Approved')) &&       (option.Outcome__c == 'Approved') ) 
        {
         otheroptions[i].Outcome__c = 'Rejected';
         needsUpdate = TRUE;
        }
     }
    }
  if (needsUpdate){
    update otheroptions;
  }
 
}

 

Thanks!!

How would I write a formula to take a regular date field (11/15/2011) and a text field that represents a time in this format (08:30 AM) into a date/time formula field? Any help is appreciated. Thanks!

 

 

I have the following trigger on the Housing_Request__c object which should create a Setup_List__c child record if the Approved_Housing_Option__c field on the housing request is not null.

 

When I edit and save a housing request I do not get any errors, however, my child record is not created. Can anyone see if I have missed something?

 

}

trigger createSetup on Housing_Request__c (after insert, after update) {  
    List <Setup_List__c> suToInsert = new List <Setup_List__c>();
    for (Housing_Request__c hr : Trigger.new) {
        if (hr.Approved_housing_option__c != null){      
        Setup_List__c sl = new Setup_List__c ();        
        sl.RecordTypeId = '012K00000000BAD';
        sl.Housing_Request__c = hr.id;
        sl.Vendor__c = hr.approved_housing_option__r.vendor__c;        
        suToInsert.add(sl);       
        }       
    } 
    try {
        insert suToInsert; 
    } catch (system.Dmlexception e) {
        system.debug (e);
    }   

I had the following trigger in place to update the Housing Request (custom object) owner ID to the current user's ID when the request status was updated to "In Process". But now I am realizing I need to trigger the owner update sooner. So I need to change to trigger when the status is "New" and since the user I want to change ownership to will not be in the record at the time I can no longer user the current user's ID to assign ownership to. Instead, I need to assign ownership to a related user (Housing_Request__c.Housing_Rep__r.Id) but every time I attempt to change ownership to this related user I get a method error. Can you help me modify this to work?

 

}

trigger ownerUpdate on Housing_Request__c (before update) {
    // no bulk processing; will only run from the UI   
    if (Trigger.new.size() == 1) {   
        // if a Housing Request has been updated to In Process
        if (Trigger.new[0].Status__c == 'In Process') {   
            // Change Trigger.old[0].OwnerId to Current User ID
            Trigger.new[0].OwnerId = UserInfo.getUserId();
        }
    }

  • September 21, 2011
  • Like
  • 0

... if I could install it without the CRM objects (opportunities, cases...) and could modify the class to work with my custom objects. Is there an app out there that does what Swarm 3 does for custom objects?

I am attempting to compare the dates from a job schedule to dates from it's child assignment schedules so I can determine which dates have not yet been assigned. So far I have a list of both jobdates and assignmentdates. My initial thought was to convert those to sets and do a minusSet to determine which dates are left. However, I am having trouble converting my date list to a set. I am getting an error that says:  Invalid initial value type LIST<Date__c> for SET<Date>

 

Here is my code for converting my job date list to a job date set:

 

 private List<Date__c> jobdates{ get {
        if(jobdates == null){
            jobdates = new list<Date__c>();
            jobdates = [select date__c, id from date__c where time_frame__c = :jobtimeframe];
        }
        return jobdates;
    } set;}
 
        private set<Date> setjobdates{ get {
        if(setjobdates == null){
            for(Date__c d : jobdates){
                setjobdates.add(d.date__c);
            }
        }
        return setjobdates;
    } set; }

 

Now, I am wondering if there is an easy fix to this or if there is another way to simply compare my two lists (jobdates and assignmentdates) without converting them to a set?

Wondering if anybody can help me with this one...

 

I have a custom button on the detail page to approve a record (which just sets an Outcome field to "Approved"). Then I have a trigger that will update all of the other options to "Rejected". The first time I approve an option record it works perfectly. That record's outcome is set to "Approved" and all of the other option records' outcomes are set to "Rejected". However, if I then go in to one of those rejected options and click the Approve button, the outcome is set to "Approved" as it should be but none of the other options' outcomes are changed to be set to "Rejected". Let me know if you have any thoughts...

 

Here is my button:

 

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")} 

alert ("Your Housing Option has been Approved. Thanks."); 

var newRecords = []; 

var c = new sforce.SObject("Housing_Options__c"); 
c.id ="{!Housing_Options__c.Id}"; 
c.Outcome__c = "Approved"; 
newRecords.push(c); 

result = sforce.connection.update(newRecords); 

window.location.reload();

 

 

Here is my trigger:

 

trigger setOutcomes on Housing_Options__c (after update) 
{
  List<ID> requestIDs = new List<ID>();
  Boolean needsUpdate = FALSE; 
    for (Housing_Options__c option: trigger.new)
    {
    requestIDs.add(option.Housing_Request__c);
    }
    List<Housing_Options__c> otheroptions = new List<Housing_Options__c>([select id, Outcome__c, Housing_Request__c from Housing_Options__c where Housing_Request__c in: requestIDs]);
    for (Housing_Options__c option: trigger.new)
    {
    for (integer i=1; i < otheroptions.size(); i++)
     {
        if ( ((Trigger.isInsert) ||       (Trigger.isUpdate) && (Trigger.oldMap.get(option.id).Outcome__c != 'Approved')) &&       (option.Outcome__c == 'Approved') ) 
        {
         otheroptions[i].Outcome__c = 'Rejected';
         needsUpdate = TRUE;
        }
     }
    }
  if (needsUpdate){
    update otheroptions;
  }
 
}

 

Thanks!!

How would I write a formula to take a regular date field (11/15/2011) and a text field that represents a time in this format (08:30 AM) into a date/time formula field? Any help is appreciated. Thanks!

 

 

I have the following trigger on the Housing_Request__c object which should create a Setup_List__c child record if the Approved_Housing_Option__c field on the housing request is not null.

 

When I edit and save a housing request I do not get any errors, however, my child record is not created. Can anyone see if I have missed something?

 

}

trigger createSetup on Housing_Request__c (after insert, after update) {  
    List <Setup_List__c> suToInsert = new List <Setup_List__c>();
    for (Housing_Request__c hr : Trigger.new) {
        if (hr.Approved_housing_option__c != null){      
        Setup_List__c sl = new Setup_List__c ();        
        sl.RecordTypeId = '012K00000000BAD';
        sl.Housing_Request__c = hr.id;
        sl.Vendor__c = hr.approved_housing_option__r.vendor__c;        
        suToInsert.add(sl);       
        }       
    } 
    try {
        insert suToInsert; 
    } catch (system.Dmlexception e) {
        system.debug (e);
    }