• WesCooper
  • NEWBIE
  • 0 Points
  • Member since 2012

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

Hey guys - I am having an issue and I just cannot figure it out. My trigger is made to create a new case and set certain fields of the new Case object. I am able to set all these fields, except for one, the Account field.

 

The Account field is a lookup field and for some reason, I am unable to set it. I have provided my code below. Any help would be greatly appreciated. 

 

 

trigger ProgDetailTriggerCase on BLND_DFDT_Project__c (after insert) {

    AssignmentRule aRule = new AssignmentRule();
    aRule = [SELECT id FROM AssignmentRule WHERE SobjectType = 'Case' AND Active = true limit 1];
    
    Database.DMLOptions dmlOpts = new Database.DMLOptions();
    dmlOpts.assignmentRuleHeader.assignmentRuleId = aRule.id;
    
    Id rtID = [select Id, name from RecordType where name = 'Implementation' and SObjectType = 'Case' limit 1].Id;
    
    Set<Id> accId = new Set<Id>();
    
    for (BLND_DFDT_Project__c pdt : Trigger.new){
            accId.add(pdt.BLND_Account_Link__c);
    }

    Map<Id, Account> accMaps = new Map<Id, Account>([SELECT Id, parentid FROM Account WHERE Id IN :accID]);
    
    for (BLND_DFDT_Project__c pdt : Trigger.new){
        Case newpdCase = new Case(
            Account = accMaps.get(pdt.BLND_Account_Link__c).parentid,
            Subject = 'New Program Detail Created',
            Priority = 'Medium',
            Status = 'New',
            Reason = 'Implementation',
            Description = 'Testing the trigger',
            RecordTypeId = rtID,
            Program_Detail__c = pdt.Id,
            Opportunity__c = pdt.BLND_Opportunity_Link__c
            ); 
            
            newpdCase.setOptions(dmlOpts);
            insert newpdcase;
            
            system.debug(newpdCase.Account);
    }
}

 

Hey guys, I am relatively new to writing triggers in SaleForce and so I am hitting a brick wall that I cannot seem to climb over. I've look on the net for the answer, but cannot seem to find it. 

 

I need to create a case after and insert is done from another object. I have no issue here; it works. Thep roblem I am having is pulling a Lookup value from the object. I'm not sure how to do this and I'm having trouble figuring it out.

 

Here is my trigger:

 

trigger MyTrigger on MyObject (after insert) {
    private String Acc;
    private String Opp;
    private String pd;

    AssignmentRule aRule = new AssignmentRule();
    aRule = [SELECT id FROM AssignmentRule WHERE SobjectType = 'Case' AND Active = true limit 1];
    
    Database.DMLOptions dmlOpts = new Database.DMLOptions();
    dmlOpts.assignmentRuleHeader.assignmentRuleId = aRule.id;
    
    Id rtID = [select Id, name from RecordType where name = 'Implementation' and SObjectType = 'Case' limit 1].Id;
    
    Case newpdCase = new Case(
        Subject = 'New Test Case Created',
        Priority = 'Medium',
        Status = 'New',
        Reason = 'Implementation',
        Description = 'Testing the trigger',
        RecordTypeId = rtID
        );
        
        newpdCase.setOptions(dmlOpts);
        insert newpdcase;
    
}

 

 

Any help would be greatly appreciated.

 

Thank you,

 

Wes

I’m having an issue with inserting a date into a custom Date field. We are parsing through a file and extracting information. One of the pieces of information that is being extracted is a date value in the following format – mm-dd-yy.

 

I am currently setting this as a Date – Date dt = date.newinstance(y,m,d). But when I run this program to insert these values to a custom Date field, the program fails and I get the following error message - Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, mailing_date: invalid date

 

I used the Dev. Console to run this block of code to see what the date format is being set as:

 

Date dts = date.newinstance(12,4,24);

system.debug(dts);

 

The result is - 09:32:17:212 USER_DEBUG [2]|DEBUG|0012-04-24 00:00:00

 

My assumption was that since I am making this a Date and not a DateTime, that the time stamp would not be included. Also, the year is showing as 0012, rather then just “12” or “2012”. I thought that the Date type has a "format" method, but apparently it doesn't, only DateTime does.

 

I cannot figure out what I am doing wrong. Any help would be greatly appreciated.

 

Thank you once again,

 

Wes Cooper

Hello, I am very new to SF and Apex code (Not new to OOP, though). I have been searching all over the net for a solution to my problem, but I cannot seem to find one. 

 

We have setup an email service to receive emails and these emails have 1 tab delimited text file attachment. The content of these text files need to be read and uploaded to a DB Object we created. 

 

Does anyone have a link on how to read through an attached text file? If I get that working, then I should be able to do the rest.

 

Any help would be greatly appreciated.

 

Thank you,

 

Wes Cooper

Hey guys - I am having an issue and I just cannot figure it out. My trigger is made to create a new case and set certain fields of the new Case object. I am able to set all these fields, except for one, the Account field.

 

The Account field is a lookup field and for some reason, I am unable to set it. I have provided my code below. Any help would be greatly appreciated. 

 

 

trigger ProgDetailTriggerCase on BLND_DFDT_Project__c (after insert) {

    AssignmentRule aRule = new AssignmentRule();
    aRule = [SELECT id FROM AssignmentRule WHERE SobjectType = 'Case' AND Active = true limit 1];
    
    Database.DMLOptions dmlOpts = new Database.DMLOptions();
    dmlOpts.assignmentRuleHeader.assignmentRuleId = aRule.id;
    
    Id rtID = [select Id, name from RecordType where name = 'Implementation' and SObjectType = 'Case' limit 1].Id;
    
    Set<Id> accId = new Set<Id>();
    
    for (BLND_DFDT_Project__c pdt : Trigger.new){
            accId.add(pdt.BLND_Account_Link__c);
    }

    Map<Id, Account> accMaps = new Map<Id, Account>([SELECT Id, parentid FROM Account WHERE Id IN :accID]);
    
    for (BLND_DFDT_Project__c pdt : Trigger.new){
        Case newpdCase = new Case(
            Account = accMaps.get(pdt.BLND_Account_Link__c).parentid,
            Subject = 'New Program Detail Created',
            Priority = 'Medium',
            Status = 'New',
            Reason = 'Implementation',
            Description = 'Testing the trigger',
            RecordTypeId = rtID,
            Program_Detail__c = pdt.Id,
            Opportunity__c = pdt.BLND_Opportunity_Link__c
            ); 
            
            newpdCase.setOptions(dmlOpts);
            insert newpdcase;
            
            system.debug(newpdCase.Account);
    }
}

 

Hey guys, I am relatively new to writing triggers in SaleForce and so I am hitting a brick wall that I cannot seem to climb over. I've look on the net for the answer, but cannot seem to find it. 

 

I need to create a case after and insert is done from another object. I have no issue here; it works. Thep roblem I am having is pulling a Lookup value from the object. I'm not sure how to do this and I'm having trouble figuring it out.

 

Here is my trigger:

 

trigger MyTrigger on MyObject (after insert) {
    private String Acc;
    private String Opp;
    private String pd;

    AssignmentRule aRule = new AssignmentRule();
    aRule = [SELECT id FROM AssignmentRule WHERE SobjectType = 'Case' AND Active = true limit 1];
    
    Database.DMLOptions dmlOpts = new Database.DMLOptions();
    dmlOpts.assignmentRuleHeader.assignmentRuleId = aRule.id;
    
    Id rtID = [select Id, name from RecordType where name = 'Implementation' and SObjectType = 'Case' limit 1].Id;
    
    Case newpdCase = new Case(
        Subject = 'New Test Case Created',
        Priority = 'Medium',
        Status = 'New',
        Reason = 'Implementation',
        Description = 'Testing the trigger',
        RecordTypeId = rtID
        );
        
        newpdCase.setOptions(dmlOpts);
        insert newpdcase;
    
}

 

 

Any help would be greatly appreciated.

 

Thank you,

 

Wes

Hello, I am very new to SF and Apex code (Not new to OOP, though). I have been searching all over the net for a solution to my problem, but I cannot seem to find one. 

 

We have setup an email service to receive emails and these emails have 1 tab delimited text file attachment. The content of these text files need to be read and uploaded to a DB Object we created. 

 

Does anyone have a link on how to read through an attached text file? If I get that working, then I should be able to do the rest.

 

Any help would be greatly appreciated.

 

Thank you,

 

Wes Cooper