• crob1212
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 3
    Replies

Greetings all,

My org has a busines process in which a customer will upload an attachment via the portal, then a user is responsible for doing something (or a number of things) with that document.  The problem is that our users have no way of knowing when an attachment has been uploaded with perpetually monitoring the records in SFDC.  So I need to develop a process by which users will be notified when an attachment is uploaded.  Through conversations with SFDC, I understand that this needs to be accomplished via a trigger.  If you have already done something like this or if you have ideas on how to do something like this, I'd love to hear them.

 

Many Thanks

Greetings All,

I am receiving the error mentioned above when trying to compile a trigger.  Actually, the error in its entirety is Method does not exist or incorret signature:[MAP:String, String].put(SOBJECT:Request__c) at line 40 column 34.

 

There is probably a pretty simple solution to this, but being new to apex, it isn't readily apparent to me.  Any assistane is geatly appreciated.

 

Here is the code:

trigger UpdateSimilarRequests on Request__c (after update) { //list will contain a concatenation of the custodian and subject List<String> subjCustList = new List<String>(); //map will contain a concatenation of the custodian and subject //but will also include the MRC Record Type Map<String, String> subjCustToRecordType = new Map<String, String>(); for(Request__c reqNew : Trigger.new) { Request__c reqOld = Trigger.oldMap.get(reqNew.Id); //if the old record type is Additional AND the old record status is not 02-Approved AND the new record status is 02-Approved if(reqOld.RecordTypeId == '01270000000Dvwh' && reqOld.Status__c != '02-Approved' && reqNew.Status__c == '02-Approved') { //add the values to the list subjCustList.add(String.valueOf(reqNew.Custodian_Lookup__c) + String.valueOf(reqNew.Subject__c)); //add the values to the map subjCustToRecordType.put(String.valueOf(reqNew.Custodian_Lookup__c) + String.valueOf(reqNew.Subject__c), reqNew.Record_Type__c); } } if(subjCustList.size() > 0) { //find the requests to update for(Request__c r : [SELECT Status__c, Custodian_Lookup__c, Client_Directive__c FROM Request__c WHERE Custodian_and_Subject__c IN : subjCustToRecordType AND isEligibleForSimilarRequestUpdate__c = 'TRUE' ]) { if(subjCustToRecordType.containsKey(r.Custodian_and_Subject__c)&& r.Record_Type__c != subjCustToRecordType.get(r.Record_Type__c)){ r.Status__c='02-Approved'; subjCustToRecordType.put(r); } } } if(subjCustList.size() > 0){ //update the requests Update subjCustList; } }

The line referenced in the error is the line tht is:

subjCustToRecordType.put(r);

 

Thanks

Message Edited by crob1212 on 03-15-2010 07:45 PM

Sorry...here is the code in a more legible format (p.s. I don't recommend using Chrome when posting messages including code.  Somehow the formatting of the code gets lost when the message is posted)

 

 

@isTest private class TestHoldAddressedOnCase { public static testMethod void testHoldAddressed() { //set up user User u = [ SELECT id FROM User WHERE alias='auser' LIMIT 1]; //Run as u System.RunAs(u) { //create a Request Request__c r = new Request__c (MRCProject__c='a0F700000028Eb5', Group__c='00G70000001CnPEEA0',Subject__c='a0270000005GLDl', Custodian_Lookup__c='0017000000YN7Mt', Record_Type__c='Academic', Status__c='10-Request Sent', Case_Priority__c='P4', Method_of_Authorization__c='Blank Auth', Source__c='Client'); insert r; //verify the request was created correctly. r = [ SELECT Id, Hold_Addressed__c FROM Request__c WHERE Id = :r.Id LIMIT 1]; system.assertEquals(FALSE, r.Hold_Addressed__c); //Create the Case (Client Directive) string testCase = 'Test Case'; Case c = new case (RecordTypeId='01270000000LtyP', Status = 'Unassigned', Related_Subject__c='a0270000005GLDl', Request__c=r.Id,Hold_Addressed__c = TRUE); //Cause the trigger to execute. insert c; //Verify that the request was updated. r = [ SELECT Id, Hold_Addressed__c FROM Request__c WHERE Id = :c.Id]; System.assertEquals(c.Hold_Addressed__c, r.Hold_Addressed__c); } } }

 

 

 

 

Hello All,

I am new to Apex and I'm pulling my hair out trying to figure out what is wrong with my code.  In a nutshell, there is a field in the Case object called Hold_Addressed__c, which is a checkbox field.  And there is a field with the same name (Hold_Addressed__C) on a custom object called Request__c.  I've written a trigger that populates the field on the custom object with the value of the field on the case.  So, if case.Hold_Addressed__c = TRUE then Request__r.Hold_Addressed__c = TRUE; same for FALSE.  The trigger is working great.  But the test class is not.  I'm getting an error stating "System.QueryException: List has no rows for assignment to SObject".  Can anyone help with this?  Many Thanks.

Here is the test class:

 

 

@isTestprivate class TestHoldAddressedOnCase{ public static testMethod void testHoldAddressed() { //set up user User u = [ SELECT id FROM User WHERE alias='auser' LIMIT 1]; //Run as u System.RunAs(u) { //create a Request Request__c r = new Request__c (MRCProject__c='a0F700000028Eb5', Group__c='00G70000001CnPEEA0',Subject__c='a0270000005GLDl', Custodian_Lookup__c='0017000000YN7Mt', Record_Type__c='Academic', Status__c='10-Request Sent', Case_Priority__c='P4', Method_of_Authorization__c='Blank Auth', Source__c='Client'); insert r; //verify the request was created correctly. r = [ SELECT Id, Hold_Addressed__c FROM Request__c WHERE Id = :r.Id LIMIT 1]; system.assertEquals(FALSE, r.Hold_Addressed__c); //Create the Case (Client Directive) string testCase = 'Test Case'; Case c = new case (RecordTypeId='01270000000LtyP', Status = 'Unassigned', Related_Subject__c='a0270000005GLDl', Request__c=r.Id,Hold_Addressed__c = TRUE); //Cause the trigger to execute. insert c; //Verify that the request was updated. r = [ SELECT Id, Hold_Addressed__c FROM Request__c WHERE Id = :c.Id]; System.assertEquals(c.Hold_Addressed__c, r.Hold_Addressed__c); } } }

 


 

Message Edited by crob1212 on 03-06-2010 06:12 AM
Message Edited by crob1212 on 03-06-2010 06:25 AM

Hello All,

Is it possible for a user (or users) to receive a notification when an attachment is added to the Notes & Attachments section of a record in SFDC?  If so, how?  Does this have to be done via trigger?

 

Many thanks 

Hi All,

I am new to Apex programming and appreciate any help you can offer.  I have a parent object (Subject__c) which has children (Conditions__c).  The child object has a field called Start_Date__c, which is a Date field.  I want a trigger that will go get the start  date for each Condition and put them in a field on the Subject called Date_s_Of_Injury__c, with each value separated by a semicolon. So, for example, if there were three child records with the Start Dates of 07/01/2001, 10/12/2002 and 12/12/2007, the field on the parent object would look something like this:  Date(s) Of Injury:  07/01/2001; 10/12/2002; 12/12/2007.   I have figured out the code to update the field on the parent if there is only one Start Date.  But I don't know how to go grab multiple start dates.  Here is the code that will add singular dates of service:

trigger UpdateDateOfInjury on Condition__c (after insert) 

{
 
  List<id> subIds = new List<id>();
 
  for(Condition__c cd: Trigger.new)
  { 
    if (cd.Start_Date_Alleged__c != NULL)  
    {
      subIds.add(cd.Subject__c);
    }
        
    system.debug('Check Ids added:' + subIds.size());

   
    List<Subject__c> subjects = [SELECT Id FROM Subject__c WHERE Id IN :subIds];

    system.debug('Check How Many Subjects retrieved:' + subjects.size());
 
    for (Subject__c s: subjects) 
    {
      s.Date_s_of_Injury__c = s.Date_s_of_Injury__c = cd.Start_Date_Alleged__c ;
    }
    
    update subjects;
  }  

}

 

 

By the way, the field on the parent object is a date field.  I tried to make it a text field but got an error b/c I couldn't make a date populate in a text field.

 

Any ideas?

 

Thanks a million. 

I have a checkbox on the case object that, when checked, I want to put a check in another checkbox on a custom object.  I can't do this through workflow b/c of the relationship between the Cases object and the custom object.  So I'm assuming that the best way to do this is via a trigger, which I've never done but am eager to learn.  Basically, it needs to do this:

(Preface: the case will be entered from a record in a custom object called Request; and will, therefore, be related to the Request.)

If Hold_Addressed__c (custom field on Cases object)=TRUE,  then look at the request with which the case is related and update Hold__c (custom field on the Request object) to TRUE.

 

Any suggesstions are appreciated.

 

Thanks

Message Edited by crob1212 on 01-03-2010 11:35 PM

I've built a custom button that changes the record type and status of the record from which it was clicked.  And it works exactly as it should when an internal user clicks it but doesn't work at all in the portal.  I've verified that the portal profile has access to both the old and the new record types.  I've also verified that field level security is not the culprit.  Any ideas???

 

Thanks

Hello All,

Is it possible for a user (or users) to receive a notification when an attachment is added to the Notes & Attachments section of a record in SFDC?  If so, how?  Does this have to be done via trigger?

 

Many thanks 

Sorry...here is the code in a more legible format (p.s. I don't recommend using Chrome when posting messages including code.  Somehow the formatting of the code gets lost when the message is posted)

 

 

@isTest private class TestHoldAddressedOnCase { public static testMethod void testHoldAddressed() { //set up user User u = [ SELECT id FROM User WHERE alias='auser' LIMIT 1]; //Run as u System.RunAs(u) { //create a Request Request__c r = new Request__c (MRCProject__c='a0F700000028Eb5', Group__c='00G70000001CnPEEA0',Subject__c='a0270000005GLDl', Custodian_Lookup__c='0017000000YN7Mt', Record_Type__c='Academic', Status__c='10-Request Sent', Case_Priority__c='P4', Method_of_Authorization__c='Blank Auth', Source__c='Client'); insert r; //verify the request was created correctly. r = [ SELECT Id, Hold_Addressed__c FROM Request__c WHERE Id = :r.Id LIMIT 1]; system.assertEquals(FALSE, r.Hold_Addressed__c); //Create the Case (Client Directive) string testCase = 'Test Case'; Case c = new case (RecordTypeId='01270000000LtyP', Status = 'Unassigned', Related_Subject__c='a0270000005GLDl', Request__c=r.Id,Hold_Addressed__c = TRUE); //Cause the trigger to execute. insert c; //Verify that the request was updated. r = [ SELECT Id, Hold_Addressed__c FROM Request__c WHERE Id = :c.Id]; System.assertEquals(c.Hold_Addressed__c, r.Hold_Addressed__c); } } }

 

 

 

 

Hello All,

I am new to Apex and I'm pulling my hair out trying to figure out what is wrong with my code.  In a nutshell, there is a field in the Case object called Hold_Addressed__c, which is a checkbox field.  And there is a field with the same name (Hold_Addressed__C) on a custom object called Request__c.  I've written a trigger that populates the field on the custom object with the value of the field on the case.  So, if case.Hold_Addressed__c = TRUE then Request__r.Hold_Addressed__c = TRUE; same for FALSE.  The trigger is working great.  But the test class is not.  I'm getting an error stating "System.QueryException: List has no rows for assignment to SObject".  Can anyone help with this?  Many Thanks.

Here is the test class:

 

 

@isTestprivate class TestHoldAddressedOnCase{ public static testMethod void testHoldAddressed() { //set up user User u = [ SELECT id FROM User WHERE alias='auser' LIMIT 1]; //Run as u System.RunAs(u) { //create a Request Request__c r = new Request__c (MRCProject__c='a0F700000028Eb5', Group__c='00G70000001CnPEEA0',Subject__c='a0270000005GLDl', Custodian_Lookup__c='0017000000YN7Mt', Record_Type__c='Academic', Status__c='10-Request Sent', Case_Priority__c='P4', Method_of_Authorization__c='Blank Auth', Source__c='Client'); insert r; //verify the request was created correctly. r = [ SELECT Id, Hold_Addressed__c FROM Request__c WHERE Id = :r.Id LIMIT 1]; system.assertEquals(FALSE, r.Hold_Addressed__c); //Create the Case (Client Directive) string testCase = 'Test Case'; Case c = new case (RecordTypeId='01270000000LtyP', Status = 'Unassigned', Related_Subject__c='a0270000005GLDl', Request__c=r.Id,Hold_Addressed__c = TRUE); //Cause the trigger to execute. insert c; //Verify that the request was updated. r = [ SELECT Id, Hold_Addressed__c FROM Request__c WHERE Id = :c.Id]; System.assertEquals(c.Hold_Addressed__c, r.Hold_Addressed__c); } } }

 


 

Message Edited by crob1212 on 03-06-2010 06:12 AM
Message Edited by crob1212 on 03-06-2010 06:25 AM
Good news regarding the BR() function: We have changed the behavior so that it inserts a new line character rather than the dreaded _BR_ENCODED_.

You should now be able to compose formulas in Workflow Field Update & Default Value formulas like

Code:
MailingStreet & BR() &
MailingCity & ", " & MailingState & " " & MailingPostalCode & BR() &
MailingCountry

This fix is now live, so give it a try.

Regards,
Eric
  • July 31, 2007
  • Like
  • 0