• Vimarsh Saxena
  • NEWBIE
  • 5 Points
  • Member since 2018

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

Hi,

I am trying to create an after insert trigger that would work on ContentDocument and create a new task record based on the type of ContentDocument. I have to go this route of creating trigger because Process Builder and Flows cannot be used with ContentDocument. I am a newbie to development and had given a shot in my Sandbox first. I believe the code is right because I don't see any syntax errors but it's actually not working. Can't figure out what's wrong. Any help is greatly appreciated! Below is my trigger:

 

trigger EmailUpload on ContentDocument (after insert) {
  List <Task> newtask = new List <Task> ();
    
    for (ContentDocument c : Trigger.new) {
                
        // here is where you check if content document uploaded is of MSG format
        if (c.FileExtension == 'msg') {
        
        Task t = new Task (); //instantiate the object to put values for future record
        
        // now assign field values to Task object that is being created
        t.Subject = 'New Email';
        t.ActivityDate = SYSTEM.TODAY();
        t.OwnerId = c.CreatedById;
        newtask.add(t);
        
        }    //end if
    }        //end for loop
    
    //once loop is done, insert new records in SF
    // dml operations might cause an error, so catch it with try/catch block.
    try {
        insert newtask; 
    } catch (system.Dmlexception e) {
        system.debug (e);
    }
}

Hi,

I am trying to create an after insert trigger that would work on ContentDocument and create a new task record based on the type of ContentDocument. I have to go this route of creating trigger because Process Builder and Flows cannot be used with ContentDocument. I am a newbie to development and had given a shot in my Sandbox first. I believe the code is right because I don't see any syntax errors but it's actually not working. Can't figure out what's wrong. Any help is greatly appreciated! Below is my trigger:

 

trigger EmailUpload on ContentDocument (after insert) {
  List <Task> newtask = new List <Task> ();
    
    for (ContentDocument c : Trigger.new) {
        
        
        // here is where you check if content document uploaded is of MSG format
        if (c.FileExtension == 'msg') {
        
        Task t = new Task (); //instantiate the object to put values for future record
        
        // now assign field values to Task object that is being created
        t.Subject = 'New Email';
        t.ActivityDate = SYSTEM.TODAY();
        t.OwnerId = c.CreatedById;
        newtask.add(t);
        
        }    //end if
    }        //end for loop
    
    //once loop is done, insert new records in SF
    // dml operations might cause an error, so catch it with try/catch block.
    try {
        insert newtask; 
    } catch (system.Dmlexception e) {
        system.debug (e);
    }
}

I am a newbie to Salesforce and just started to work with Flows. My flow is creating a record and I want to navigate to the new created record when the flow finishes. I read this can be done by adding a retURL parameter here https://help.salesforce.com/articleView?id=vpm_url_set_retURL.htm&type=5 but I can't edit the flow URL to add the parameter. Please help

Hi,

I am trying to create an after insert trigger that would work on ContentDocument and create a new task record based on the type of ContentDocument. I have to go this route of creating trigger because Process Builder and Flows cannot be used with ContentDocument. I am a newbie to development and had given a shot in my Sandbox first. I believe the code is right because I don't see any syntax errors but it's actually not working. Can't figure out what's wrong. Any help is greatly appreciated! Below is my trigger:

 

trigger EmailUpload on ContentDocument (after insert) {
  List <Task> newtask = new List <Task> ();
    
    for (ContentDocument c : Trigger.new) {
                
        // here is where you check if content document uploaded is of MSG format
        if (c.FileExtension == 'msg') {
        
        Task t = new Task (); //instantiate the object to put values for future record
        
        // now assign field values to Task object that is being created
        t.Subject = 'New Email';
        t.ActivityDate = SYSTEM.TODAY();
        t.OwnerId = c.CreatedById;
        newtask.add(t);
        
        }    //end if
    }        //end for loop
    
    //once loop is done, insert new records in SF
    // dml operations might cause an error, so catch it with try/catch block.
    try {
        insert newtask; 
    } catch (system.Dmlexception e) {
        system.debug (e);
    }
}

Hi,

I am trying to create an after insert trigger that would work on ContentDocument and create a new task record based on the type of ContentDocument. I have to go this route of creating trigger because Process Builder and Flows cannot be used with ContentDocument. I am a newbie to development and had given a shot in my Sandbox first. I believe the code is right because I don't see any syntax errors but it's actually not working. Can't figure out what's wrong. Any help is greatly appreciated! Below is my trigger:

 

trigger EmailUpload on ContentDocument (after insert) {
  List <Task> newtask = new List <Task> ();
    
    for (ContentDocument c : Trigger.new) {
        
        
        // here is where you check if content document uploaded is of MSG format
        if (c.FileExtension == 'msg') {
        
        Task t = new Task (); //instantiate the object to put values for future record
        
        // now assign field values to Task object that is being created
        t.Subject = 'New Email';
        t.ActivityDate = SYSTEM.TODAY();
        t.OwnerId = c.CreatedById;
        newtask.add(t);
        
        }    //end if
    }        //end for loop
    
    //once loop is done, insert new records in SF
    // dml operations might cause an error, so catch it with try/catch block.
    try {
        insert newtask; 
    } catch (system.Dmlexception e) {
        system.debug (e);
    }
}

I am a newbie to Salesforce and just started to work with Flows. My flow is creating a record and I want to navigate to the new created record when the flow finishes. I read this can be done by adding a retURL parameter here https://help.salesforce.com/articleView?id=vpm_url_set_retURL.htm&type=5 but I can't edit the flow URL to add the parameter. Please help

I've built a Flow that creates a new record for a Custom object. I'm setting a variable to the new id in the Flow, but I think my VF page is reading its value at creation, which is null. How do I set a page reference to the new id so I can redirect to the new Dispatch__c object? 

 

Controller:

public class DispatchFlowController {
	
	public Flow.Interview.New_Dispatch_Flow theFlow {get; set;}
		
	public PageReference getNewDispatchRecord(){
		if(theFlow == null)
			return null;
		else
			return new PageReference('/' + theFlow.NewDispatchId);
	}
	
}

 VF Page:

<apex:page Controller="DispatchFlowController" >
<flow:interview name="New_Dispatch_Flow" interview="{!theFlow}" 
	finishLocation="{!NewDispatchRecord}"/>
</apex:page>

 note, if I hard-code the new PageReference to an existing id it does redirect to that object instance, but obviously I don't know what id my new object will have until the end of the Flow.

We have created a flow that creates an Opportunity and we want the "finishlocation" of the flow, where they end up when they click "Finish", to be the newly created Opportunity. I know that we will have to create a VF page and controller to pass the OpptyID (once created) back to the VF page and set as the finishlocation, but can't figure out how to do it. Any ideas?