• Brian Good 13
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies
I've inserted a simple case formula into my SAQL query when constructing tables to change the month number into the name:
 
(case 'custom_field_Month' when "01" then "January" when "02" then "February"  when "03" then "March"  when "04" then "April"  when "05" then "May"  when "06" then "June"  when "07" then "July"  when "08" then "August"  when "09" then "September"  when "10" then "October"  when "11" then "November" else "December" end) as 'Month_Name'
 
However, I'm trying to insert it into a table with multiple coalesce functions and I'm not quite sure where to put it.  I've tried a few places but continually get errors when trying to run the query (I've run into the Cogroup projection idtoken requires stream identifier - error most often).  Any help on where this case formula should go (do I need to put it multiple times in the each of the "result = foreach result generate..." line?)  Here is an example of my SAQL table query:
 
q = load "ProposalandContractData";
q = filter q by 'xs_Final_Version__c' == "true";
q_A = filter q by date('xs_Client_Submission_Date__c_Year', 'xs_Client_Submission_Date__c_Month', 'xs_Client_Submission_Date__c_Day') in ["current fiscal_year".."current fiscal_year"];
q_B = filter q by date('xs_Client_Submission_Date__c_Year', 'xs_Client_Submission_Date__c_Month', 'xs_Client_Submission_Date__c_Day') in ["current fiscal_year".."current fiscal_year"];
q_A = group q_A by rollup('xs_Client_Submission_Date__c_Month');
q_A = order q_A by ('xs_Client_Submission_Date__c_Month' asc nulls first);
q_B = group q_B by rollup('xs_Client_Submission_Date__c_Month');
q_B = order q_B by ('xs_Client_Submission_Date__c_Month' asc nulls first);
result = group q_A by 'xs_Client_Submission_Date__c_Month' full, q_B by 'xs_Client_Submission_Date__c_Month';
result = foreach result generate coalesce(q_A.'xs_Client_Submission_Date__c_Month', q_B.'xs_Client_Submission_Date__c_Month') as 'xs_Client_Submission_Date__c_Month', count(q_A) as 'A', sum(q_B.'Total_Fees_Proposed__c') as 'B', coalesce(grouping(q_A.'xs_Client_Submission_Date__c_Month'), grouping(q_B.'xs_Client_Submission_Date__c_Month')) as 'grouping_xs_Client_Submission_Date__c_Month';
summary = filter result by 'grouping_xs_Client_Submission_Date__c_Month' == 1;
result = filter result by 'grouping_xs_Client_Submission_Date__c_Month' == 0;
result = order result by ('xs_Client_Submission_Date__c_Month' asc nulls last);
result = limit result 2000;
result = union result, summary;
Hello,

I'm utilizing the Database.LeadConvert class invoked from a flow to auto convert lead records.  I also want to set the AccountId and ContactId (shows in bold/italic below as the variables ExistingAccountID and ExistingContactId) from fields I am populating on the Lead record.  I'm not quite sure how to select and declare them in the class.  I am only converting one record at a time and I will be passing the ID variable (LeadIds) from a Flow to the Apex class, not sure if that makes a difference as this looks like a mass convert for multiple Lead records.  This is the method I'm using from Automation Champion:

Public class AutoConvertLeads
{ @InvocableMethod
public static void LeadAssign(List<Id> LeadIds)
{
LeadStatus CLeadStatus= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true Limit 1];
List<Database.LeadConvert> MassLeadconvert = new List<Database.LeadConvert>();
for(id currentlead: LeadIds){
Database.LeadConvert Leadconvert = new Database.LeadConvert();
Leadconvert.setLeadId(currentlead);
Leadconvert.setAccountId(ExistingAccountId);
Leadconvert.setContactId(ExistingContactId);

Leadconvert.setConvertedStatus(CLeadStatus.MasterLabel);
Leadconvert.setDoNotCreateOpportunity(TRUE); //Remove this line if you want to create an opportunity from Lead Conversion
MassLeadconvert.add(Leadconvert);
}
if (!MassLeadconvert.isEmpty())
{
List<Database.LeadConvertResult> lcr = Database.convertLead(MassLeadconvert);
}
}
}
Hello,

I'm utilizing the Database.LeadConvert class invoked from a flow to auto convert lead records.  I also want to set the AccountId and ContactId (shows in bold/italic below as the variables ExistingAccountID and ExistingContactId) from fields I am populating on the Lead record.  I'm not quite sure how to select and declare them in the class.  I am only converting one record at a time and I will be passing the ID variable (LeadIds) from a Flow to the Apex class, not sure if that makes a difference as this looks like a mass convert for multiple Lead records.  This is the method I'm using from Automation Champion:

Public class AutoConvertLeads
{ @InvocableMethod
public static void LeadAssign(List<Id> LeadIds)
{
LeadStatus CLeadStatus= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true Limit 1];
List<Database.LeadConvert> MassLeadconvert = new List<Database.LeadConvert>();
for(id currentlead: LeadIds){
Database.LeadConvert Leadconvert = new Database.LeadConvert();
Leadconvert.setLeadId(currentlead);
Leadconvert.setAccountId(ExistingAccountId);
Leadconvert.setContactId(ExistingContactId);

Leadconvert.setConvertedStatus(CLeadStatus.MasterLabel);
Leadconvert.setDoNotCreateOpportunity(TRUE); //Remove this line if you want to create an opportunity from Lead Conversion
MassLeadconvert.add(Leadconvert);
}
if (!MassLeadconvert.isEmpty())
{
List<Database.LeadConvertResult> lcr = Database.convertLead(MassLeadconvert);
}
}
}

I am trying to create a before-insert trigger on EmailMessage, so that when a user logs an email from the Outlook Integration, I can set the RelatedToId field based on the email sender (FromAddress).

What I am finding in my testing, however, is that both FromAddress and ValidatedFromAddress are NULL on insert! Perhaps due to how the Outlook Integration inserts email records - perhaps it follows up the insert with an update to populate the FromAddress field.

Unfortunately, I must put my logic in the before-insert - you are only allowed to set RelatedToId on insert.

(1) Do any of you have more details around the behavior of the Outlook Integration and the From fields that might help me?

(2) Can anyone see another solution to be able to programmatically set the RelatedToId for tracked emails, based on the sender, other than my approach of the before-insert trigger on EmailMessage?

I have considered moving my logic to an after insert, and trying to delete the original email and recreate it with all the right information, but that seems extreme and I am concerned about the impact the changing id (due to delete and create new) will have on the Outlook Integration.

Thanks to all for any help you can provide!
Scott Kostojohn