• Jon S
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
I've been asked to update an Opportunity lookup field (looks up Custom Object "Threshold") based on 3 Opportunity picklist values (they are also dependant picklists) with a Threshold record id that matches those 3 picklist values. 

Opportunity picklist fields:
a1. Market
b1. Vertical
c1. Segment

Threshold fields:
a2. Market (Custom Field)
b2. Record Type
c2. Segment (Standard Name Field)

Conceptual plan:
When a1,b1,c1  are selected, update lookup to Threshold with Threshold record that matches a2,b2,c2 to a1,b1,c1

I am thinking on using process builder to set the criteria which covers {a1,b1,c1 are selected} I am stuck finding a way to create a formula that pulls the record based on matching the Opportunity picklist values.

Thanks in advance!
  • April 25, 2017
  • Like
  • 0
Hi all,

I'm not very knowledgable in apex but I'm learning. I have a form that feeds information into salesforce and creates the Account object when submitted. When a person fills out the form and is required to upload a document, the form outputs a url of that document which populates a URL field in salesforce.

My goal is to save the uploaded documents as an attachment to the newly created Account object.

My issue is that I do not know (if there is way) how to somehow download that file from the form's output URL and save the actual document as the attachment for the Account object.

Also if there if anybody has suggestions on on re-writting the code in a better way, that'd be much aprreciated.

Thanks!

Apex Class:
public with sharing class CreateFileFromAcc {
    public void createFiles (List<Account> accsFromTrigger){ 
       
//The 4 custom fields output URLs
//Signed_EFT__c
//Uploaded_W_9_W_8__c
//COI_TEXT__c
//Signed_MSA__c

       	for(Account currentAccount : accsFromTrigger)    
        {
        Blob txtEft = Blob.valueOf(currentAccount.Signed_EFT__c);
        Attachment attach = new Attachment();
        attach.ParentId = currentAccount.Id;
        attach.Name = currentAccount.EFT_Name__c;
        attach.Body = txtEft;
        insert attach;
        }
        for(Account currentAccount : accsFromTrigger)    
        {
        Blob txtW9 = Blob.valueOf(currentAccount.Uploaded_W_9_W_8__c);
        Attachment attach = new Attachment();
        attach.ParentId = currentAccount.Id;
        attach.Name = currentAccount.W9_Name__c;
        attach.Body = txtW9;        
        insert attach;
        }
   		for(Account currentAccount : accsFromTrigger)    
        {
        Blob txtCoi = Blob.valueOf(currentAccount.COI_TEXT__c);
        Attachment attach = new Attachment();
        attach.ParentId = currentAccount.Id;
        attach.Name = currentAccount.COI_Name__c;
        attach.Body = txtCoi;
        attach.ContentType = currentAccount.COI_TEXT__c;        
        insert attach;
        }
        for(Account currentAccount : accsFromTrigger)    
        {
        Blob txtMsa = Blob.valueOf(currentAccount.Signed_MSA__c);
        Attachment attach = new Attachment();
        attach.ParentId = currentAccount.Id;
        attach.Name = currentAccount.MSA_Name__c;
        attach.Body = txtMsa;        
        insert attach;
        }
    }
}
Apex Trigger:
trigger CreateAccFile on Account (after insert)
{
	for (Account ac : Trigger.New)
	{
		if (ac.RecordTypeId == 'Test')//ACCOUNT RECORDTYPE
		{
	    CreateFileFromAcc cc = new CreateFileFromAcc();
	    cc.createFiles (Trigger.new);
		}
	    else
	    {
	    	createFileFromAcc cc = NULL;
	    }
	} 
}

 
  • June 21, 2016
  • Like
  • 0
I've been asked to update an Opportunity lookup field (looks up Custom Object "Threshold") based on 3 Opportunity picklist values (they are also dependant picklists) with a Threshold record id that matches those 3 picklist values. 

Opportunity picklist fields:
a1. Market
b1. Vertical
c1. Segment

Threshold fields:
a2. Market (Custom Field)
b2. Record Type
c2. Segment (Standard Name Field)

Conceptual plan:
When a1,b1,c1  are selected, update lookup to Threshold with Threshold record that matches a2,b2,c2 to a1,b1,c1

I am thinking on using process builder to set the criteria which covers {a1,b1,c1 are selected} I am stuck finding a way to create a formula that pulls the record based on matching the Opportunity picklist values.

Thanks in advance!
  • April 25, 2017
  • Like
  • 0
Hi all,

I'm not very knowledgable in apex but I'm learning. I have a form that feeds information into salesforce and creates the Account object when submitted. When a person fills out the form and is required to upload a document, the form outputs a url of that document which populates a URL field in salesforce.

My goal is to save the uploaded documents as an attachment to the newly created Account object.

My issue is that I do not know (if there is way) how to somehow download that file from the form's output URL and save the actual document as the attachment for the Account object.

Also if there if anybody has suggestions on on re-writting the code in a better way, that'd be much aprreciated.

Thanks!

Apex Class:
public with sharing class CreateFileFromAcc {
    public void createFiles (List<Account> accsFromTrigger){ 
       
//The 4 custom fields output URLs
//Signed_EFT__c
//Uploaded_W_9_W_8__c
//COI_TEXT__c
//Signed_MSA__c

       	for(Account currentAccount : accsFromTrigger)    
        {
        Blob txtEft = Blob.valueOf(currentAccount.Signed_EFT__c);
        Attachment attach = new Attachment();
        attach.ParentId = currentAccount.Id;
        attach.Name = currentAccount.EFT_Name__c;
        attach.Body = txtEft;
        insert attach;
        }
        for(Account currentAccount : accsFromTrigger)    
        {
        Blob txtW9 = Blob.valueOf(currentAccount.Uploaded_W_9_W_8__c);
        Attachment attach = new Attachment();
        attach.ParentId = currentAccount.Id;
        attach.Name = currentAccount.W9_Name__c;
        attach.Body = txtW9;        
        insert attach;
        }
   		for(Account currentAccount : accsFromTrigger)    
        {
        Blob txtCoi = Blob.valueOf(currentAccount.COI_TEXT__c);
        Attachment attach = new Attachment();
        attach.ParentId = currentAccount.Id;
        attach.Name = currentAccount.COI_Name__c;
        attach.Body = txtCoi;
        attach.ContentType = currentAccount.COI_TEXT__c;        
        insert attach;
        }
        for(Account currentAccount : accsFromTrigger)    
        {
        Blob txtMsa = Blob.valueOf(currentAccount.Signed_MSA__c);
        Attachment attach = new Attachment();
        attach.ParentId = currentAccount.Id;
        attach.Name = currentAccount.MSA_Name__c;
        attach.Body = txtMsa;        
        insert attach;
        }
    }
}
Apex Trigger:
trigger CreateAccFile on Account (after insert)
{
	for (Account ac : Trigger.New)
	{
		if (ac.RecordTypeId == 'Test')//ACCOUNT RECORDTYPE
		{
	    CreateFileFromAcc cc = new CreateFileFromAcc();
	    cc.createFiles (Trigger.new);
		}
	    else
	    {
	    	createFileFromAcc cc = NULL;
	    }
	} 
}

 
  • June 21, 2016
  • Like
  • 0