• cloudstreamer
  • NEWBIE
  • 50 Points
  • Member since 2015

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

Greetings All. First I am new to APEX but trying to grasp the funcitonality and coding language as best I can. I have included the lastest Trigger I have created. It successfully retrieves multiselect picklist values and creates new tasks related to the values that were selected and populates the activities related list on the Account detail page.
 
What I am trying to figure out, is how to populate the Related Contact name in the newly created task. I believe WhoId will work but not sure how to include this is the code to look across the Account record and retrieve the Related Contact. I hope I explained this well.
 
Any suggestions? I believe a SOQL statement would work but I am thinking the WHoId should as well.

Tasks Creation from Multi-Select Picklist Values

Account Activities Created from Picklist
Hi,

We are looking at pushing data from salesforce to another application using their APIs.
The business use case is that whenever the records in certain salesforce objects are updated,  insert some fields of those records into some staging tables of the other application.
The other application team is in the process of building the APIs that can be used by salesforce for this purpose and the idea is to use APIs  apex callouts ( HTTP callouts) to push data into staging tables of the other application. 
We have the following questions
Are there any specific criteria that the web services API from the other application follow so that we can integrate it with salesforce without issues?
Since there are limits on number of callouts per apex transaction, what would be the best way to go about this integration? Best practices for performing Exception/API downtime handling? 
Will using a middle ware ( ETL tool like informatica cloud) to perform this integration between the two applications reduce the complexity?


Any guidance would be appreciated.
Thanks
 
Hi,

I have a class the returns the set of records based on lastmodified date. So how to write a test class and test the results of that class ..

In a test class, If I instantiate a class and call the method then it covers me 100%. Not sure how to verify the results 

In the below class I am using custom labels to store the number of hours 
Apex class
 
public with sharing class UnclaimCases
{
    public list<case> caseami {get;set;}
    public string strhours = Label.DateFilter;
    public integer hours = integer.valueof(strhours);
    Datetime currenttime = system.now();
    datetime  acttime  = currenttime.addhours(-hours);
    public final static Id custid = Schema.SObjectType.case.getRecordTypeInfosByName().get('Support').getRecordTypeId();   
    
    public UnclaimedAMICases()
    {
     
     caseami = [Select CaseNumber,Priority,Response_Due_Date__c,Response_time_elapsed__c from case where RecordTypeID =:custid AND (Status = 'Unclaimed' OR Status ='Escalated' ) AND Product_Type__c = 'A' AND Owner.Name = 'T Queue' AND LastModifiedDate >: acttime  AND LastModifiedDate < : currenttime  ORDER BY Priority  LIMIT 10000 ];
    }
    
    public pagereference inc()
     {
         Datetime currenttimeami = system.now();
         datetime  acttimeami  = currenttime.addhours(-hours);
         caseami = [Select CaseNumber,Priority,Response_Due_Date__c,Response_time_elapsed__c from case where RecordTypeID =:custid AND (Status = 'Unclaimed' OR Status ='Escalated' ) AND Product_Type__c = 'A' AND Owner.Name = 'T Queue' AND LastModifiedDate >: acttimeami  AND LastModifiedDate <: currenttimeami ORDER BY Priority LIMIT 10000 ];
         system.debug('caseami' + caseami );
         system.debug(' current datetime value ' + currenttimeami );
         system.debug(' act datetime value ' + acttimeami );
        return null;
    }
    

}

 
  • August 19, 2016
  • Like
  • 0

Greetings All. First I am new to APEX but trying to grasp the funcitonality and coding language as best I can. I have included the lastest Trigger I have created. It successfully retrieves multiselect picklist values and creates new tasks related to the values that were selected and populates the activities related list on the Account detail page.
 
What I am trying to figure out, is how to populate the Related Contact name in the newly created task. I believe WhoId will work but not sure how to include this is the code to look across the Account record and retrieve the Related Contact. I hope I explained this well.
 
Any suggestions? I believe a SOQL statement would work but I am thinking the WHoId should as well.

Tasks Creation from Multi-Select Picklist Values

Account Activities Created from Picklist
Hello Gurus,
Need some understanding of how triggers work.

Wrote this Code (SFDC99)
Trigger

When I did a Debug, I got this ..
Debug
Trigger Executed Twice ???
Tried RunOnce..
RunOnce
And Got this ..

Debug1
Only Before Trigger is Executed .. Very Confused ..
Can someone please explain how triggers work ??

Thanks,
Raghu
I am trying to create an Apex Trigger that performs a Rollup from a custom object to Contacts. Here is the error that I am receiving: Didn't understand relationship 'Assignments__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.

Below is the code:
 
trigger RollupActiveAssigmentLevelsToContact on pse__Assignment__c (after insert, after update, after delete) {
    
    set<Id> set_id = new set<Id>();
    
    List<Contact> con_list = new List<Contact>();
    
    if(trigger.isInsert || trigger.isUpdate){
        for(pse__Assignment__c myAssignment : trigger.New) {
            set_id.add(myAssignment.pse__Resource__c);
        }
    }
    else if(trigger.isDelete){
        for(pse__Assignment__c myAssignment : trigger.Old){
            set_id.add(myAssignment.pse__Resource__c);
        }
    }
    
    if(trigger.isAfter && (trigger.isInsert || trigger.isUpdate || trigger.isDelete)){
        con_list = [SELECT id,Total_Levels__c, (SELECT id,name FROM Assignments__r WHERE Active_Assignment__c = TRUE) FROM Contact WHERE id IN :set_id];
        
        for(Contact con : con_list){
            if(con.Assignments__r.size()>0)
                con.Total_Levels__c = con.Assignments__r.size();
            else
                con.Total_Levels__c = 0;
        }
        if(!con_list.isEmpty())
        update con_list;
    }
}

Here is a snip of the Child Relationship name:

User-added image

Any and all help would be greatly appreciated!
Hi,  I receive the following error in a test class but have not been able to repeat them in non test running scenarios.

"System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_EXECUTE_FLOW_TRIGGER, The record couldn’t be saved because it failed to trigger a flow. 
A flow trigger failed to execute the flow with version ID 301O00000008hM6. 
Contact your administrator for help.: []"

Does anyone know if there could be an issue running flows in test class contexts but not otherwise?

Thanks.

Hi ,

 

     I am confused between synchronous and asynchronous can any one explain me from the scratch what are they actually , and when we use the @future annotation . Please Help me  !!!

 

 

Help is highly appreciated.

 

Thanks in Advance. 

  • June 22, 2013
  • Like
  • 2