• Douglas C. Ayers
  • NEWBIE
  • 70 Points
  • Member since 2014
  • Salesforce MVP
  • douglascayers.com


  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 15
    Replies
Hi everyone,

Here is my business requirement:

On the standard Quote object, I have a custom checkbox field called PO_Attached__c. If a File is uploaded to a Quote record, PO_Attached__c should be updated to true. I currently achieve this functionality using the Attachments functionality by use of an Apex trigger.

However, we are now migrating to Files. I have updated my code block as below. It saves fine, but the checkbox is never updated. Any ideas why? Thanks in advance.
 
trigger quoteAttachment2 on ContentDocumentLink (after insert) {

                        List<Quote> listOfQuote = [select id from Quote where id =: Trigger.New[0].LinkedEntityId];
                        if(listOfQuote.size()>0)
                        {
                                    listOfQuote[0].PO_Attached__c = true;
                                    update listOfQuote;
                        }                                                                   
            }

 
        I am trying to save a content version document.Below is what I am doing 

      qr = partner_connection.query("SELECT VersionData from ContentVersion WHERE ContentDocumentID = '" + id + "'");
             
        System.out.println(qr.getSize() > 0);  //returns false.
Hi everyone,

Here is my business requirement:

On the standard Quote object, I have a custom checkbox field called PO_Attached__c. If a File is uploaded to a Quote record, PO_Attached__c should be updated to true. I currently achieve this functionality using the Attachments functionality by use of an Apex trigger.

However, we are now migrating to Files. I have updated my code block as below. It saves fine, but the checkbox is never updated. Any ideas why? Thanks in advance.
 
trigger quoteAttachment2 on ContentDocumentLink (after insert) {

                        List<Quote> listOfQuote = [select id from Quote where id =: Trigger.New[0].LinkedEntityId];
                        if(listOfQuote.size()>0)
                        {
                                    listOfQuote[0].PO_Attached__c = true;
                                    update listOfQuote;
                        }                                                                   
            }

 
I've followed the instructions below from the 'Build an App Home Lightning Page' in trailhead and keep getting an error when I attempt to save.  The error only seems to appear because I am adding the app to the Lightning experience; however, since this is in the directions I'm not sure how to overcome it.  I've even attempted a new playground and started over but received the same error.

Link to Instructions
https://trailhead.salesforce.com/modules/lightning_app_builder/units/lightning_app_builder_apphome

Error Message: (Pops up when I attempt to activate it after adding it to the Lightning Experience apps
We had trouble processing the request. We've reported the problem to Customer Support with error ID: -406461702

Any help would be greatly appreciated!


Instructions from Link (above):
Add Your App Page to Salesforce1 and Lightning Experience
Just like the other pages, your users can’t access your app page until you activate it. During activation, you can customize the page’s custom tab label, adjust its visibility, and set its position in the Salesforce1 navigation list and Lightning Experience app navigation bars, all in one place.
Click Activation.
Don’t change the app name.
By default, the label that you give the Lightning page is used as the label for its custom tab.
Change the icon to the blue lightning bolt icon.
The icon that you choose here is used as the icon for the app in Salesforce1 and for the page in Lightning Experience.
Keep the tab’s visibility open to all users.

Tip
The Activate for the System Administrator profile only setting is useful while you’re working on your Lightning page. Restricting your page to administrators only means that you can see and test the page, but your users can’t see it until you’re ready to expose it to them.
Click the Lightning Experience tab.
Select a Lightning app, and click Add page to app.The page you’re adding to the menu appears in the second position by default. Let’s leave it there. If you put it into the top position, it becomes the landing page for all your Lightning Experience users.
Click the Salesforce1 tab.
Select the Salesforce1 Navigation Menu, and click Add page to app.
By default, new pages you add to the Salesforce1 menu appear below the Smart Search Items menu item. If you leave the Top Accounts and Opportunities page there, it will appear in the Apps section of the Salesforce1 menu. We don’t want that, so let’s move it up.
Drag the page to below the Today menu item.
Click Save.
Your app home page is now ready for your Salesforce1 and Lightning Experience users!
I have tried to create a Batch Class on the ContentDocumentLink. The querylocator in the start method is returning some records but it is not able to execute the execute() method. I am getting Internal Salesforce.com Error. May I know is there any limitations to this object?

Here is the code snippet I am using:
 
global class CommunityActivityJob implements Database.Batchable<sObject>,Database.AllowsCallouts ,Database.Stateful {
    global Database.QueryLocator start(Database.BatchableContext BC) {
    List<String> linked = new List<String>();
    linked.add('00528000000M2xj');
       String query = 'Select Id, ContentDocumentId, LinkedEntityId, ShareType, Visibility from ContentDocumentLink Where LinkedEntityId In :linked ';
        System.debug('===START==='+Database.query(query));
        return Database.getQueryLocator(query);
    }
     global void execute(Database.BatchableContext BC, List<sObject> scope) {
        System.Debug('===INSIDE EXECUTE==='+scope);
        }
    global void finish(Database.BatchableContext BC) {
        System.debug('===Inside Finish===');
    }

 
I have added a VF page to a lightning app builder. I want to know how to pass a record id to the VF as URL PARAMETER. Please let me know asap.
I'm trying to implement salesforce as IDP and Google or PHP web application as SP. Which requires Connected APP to be created in the IDP side. I created that one as well but when I Enable the "User Provisioning" in connected app it has some steps for the configuration in the User Provisioning Wizard. As soon as I open the Wizard it requires the User Provisioning Flow for connected Apps. I want to create it but there is not so much of information available in salesforce knowledge articles. Can you please help me in getting the understanding of it.   According to the video : https://www.youtube.com/watch?v=xCgy9ywYzuY    Vikas Jain explains the configuration but he also mentioned that there should be packages on the app exchange for the flow Creation. But I cannot see any packages related to it on the appExchange.  I really want to know the steps to create the User Provisioning Flow for Connected apps or the Apex Class Parameters for it.
I have a lightning component which invokes a third party popup window as a lightbox. The window is served from another domain.
I would like for when that thrid party window closes to call a JavaScript method in my Lightning component to receive some data. 

The best way I found to pass the results is via window.postMessage because the thirda party window and the lightning components are from different domains. 
The quiestion I have is how to receid that postMessage even from my Lightning component. 

I tried adding the below method to my Lighting component's controller but it did not work: 
 doInit : function(component, event, helper) {
        var listener = function(event) {
           //Do work here
       }
        if (addEventListener){
              addEventListener("message", listener, false);
        } else {
              attachEvent("onmessage", listener);
        }
    },

Could you please help me figure this out.
I am previewing my lighting component ov vf page ,below is the code for same.
 
<apex:page standardController="Opportunity" standardStylesheets="false" showHeader="false" sidebar="false">
   
    <!-- Include a JavaScript file in your Visualforce page -->
    <apex:includeScript value="/lightning/lightning.out.js" />
    
    <div id="lightning" />

    <script>
    //Tell your Visualforce page to use ExposeVF Lightning app
        var opportunityId = "{!$CurrentPage.parameters.id}";
        $Lightning.use("c:HelloComponentApp", function() {
            // Write a function that creates the component on the page
          $Lightning.createComponent("c:HelloComponent",
          {"opportunityId" : opportunityId},
          "lightning",
          function(cmp) {
            // do some stuff
            
          });
        });
    </script>

</apex:page>

I am recieving below error.
Something has gone wrong. info.$component$.$isValid$ is not a function. Please try again.

Any help would be appreciated .
I'm just learning triggers and have a relatively simple goal.  When a new task is created I need to copy the contents of a custom field on the Lead object and put it in a custom field on the Task object.

I've been reading here for about 4 hours and the triggers proposed are significantly more complex.  However, based on my reading here is a trigger that I assembled.  Note that lead.type__c is the source field and task.account_type__c is the destination field.

trigger UpdateAccountType on Task (after update) {
    Set<Id> leadIds=new Set<Id>();
    for(Task t : Trigger.new){
    if(String.valueOf(t.whoId).startsWith('00Q')==TRUE){   //check if the task is associated with a lead
        if( !leadIds.contains(t.whoid)){
            leadIds.add(t.whoId);
            t.Account_Type__C = lead.Type__c;
            }}}}

Can anyone help with this or, have I taken a wrong turn and need to start from stratch?

TIA
Hi..
I am working with custom meta data type.. now i need to update record of custom  metadata type by edit button in vf page..
so please tell me can we update record of custom metadata  in vf page..

Thanks and regards,
Nansi kela..
 
Any idea how to move old notes to the new enhanced notes and maintain the original owner/creator and date/time?
Hi, 
I am trying to build a component int Aura lightning framework and I found out that there is a know issue with "force:inputField" tag. force:inputfiled tag for picklist values is disabled by default and I saw some work around to activate it by removing attribute "disabled", but for some reason my not able to achieve it. Need your help to find out  the issue.  here is my Code. 
**************

test.cmp code: 

<div class="form-group">
              
                <div id="contact_Type" class="col-sm-10">
                    <force:inputField aura:id="contactType" value="{!v.contact.Contact_Type__c}" />
               </div>
           </div>

testController.js : 
({
    init : function(component, event, helper) {
        
              
 
        console.log(' in init : ');
        
    },
    
    newContact : function(component, event,helper){
        
        console.log("in newcontact");
        
        var contact = component.get("v.contact");
        var contactType = component.find("contactType");
        
        contact["Contact_Type__c"] = contactType.get("v.value") ;
        
        console.log("contact firstname : "+contact["firstName"]);
        console.log("contact Type "+ contact["Contact_Type__c"]);
        
        helper.insertContact(component, contact);
        
    }
    
    
})


TestRenderer.js


({
    // Your renderer method overrides go here
    // 
    render : function(cmp){
        
         var ret = this.superRender();
        
         var element = cmp.find("contactType");
        
        
        var contactType = element.getElement();
        
        console.log('contactType has disabled attr ?  '+  contactType.hasAttribute("disabled"));
        
         contactType.removeAttribute("disabled");
       
        return ret; 
    }
})



In the browser console contactType.hasAttribute('disabled'); is comming up as False. So contactType (element) doesnot have that attribute at the time of render. I think the issue is with the order of running "render()" and actual compnent rendering. 
 
  • November 18, 2015
  • Like
  • 0
Hi, guys.

I have a strange problem here, which really pisses me off :(

So it is very simple, just typing in execute anonymous:
Account acc;
acc.getCloneSourceId();

Gives me an error:
"Compile error at line 2 column 1
Method does not exist or incorrect signature: [Account].getCloneSourceId()"

According to this (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_sobject.htm)article, this method should work with any SObject, but it doesn't work with any object...
Please, tell me what am I missing.



Thanks!
  • October 16, 2015
  • Like
  • 0
Hi community,

I'm not a developer, but was working on a trigger that will update a field on the Lead Object (Trigger_Email_on_Outstanding_Task__c (checkbox) on Lead) when the corresponding field on the related task is updated (Trigger_Email_on_Outstanding_Task__c (checkbox) on Task).  This is due to the limitation of not being able to create cross-object workflows.  So if the custom field is checked on the Task, then it'll update the custom field on the Lead.

Seems simple enough, but again, I'm not a developer so even the simple codes can seem difficult:

What i have is below:

Trigger TriggerTaskNotification on Task (after insert, after update) {


    List<Id> leadIds=new List<Id>();
    for(Task t:trigger.new){
        if(t.Trigger_Email_on_Outstanding_Task__c==true){
            if(String.valueOf(t.whoId).startsWith('00Q')==TRUE){//check if the task is associated with a lead
                leadIds.add(t.whoId);
            }//if 2
        }//if 1
    }//for
    List<Lead> leadsToUpdate=[SELECT Id, Trigger_Email_on_Outstanding_Task__c FROM Lead WHERE Id IN :leadIds AND Trigger_Email_on_Outstanding_Task__c= True];
    For (Lead l:leadsToUpdate){
       
    }//for
   
    try{
        update leadsToUpdate;
    }catch(DMLException e){
        system.debug('Leads were not all properly updated.  Error: '+e);
    }
}


Doesn't seem to work, can someone point me to the fix for this, it's all greek to me.

I am attempting to design a trigger to insert new Content (ContentVersion) when a new attachment is added.  We are switching from using attachments to Content.  However, the majority of files are added through via the desktop email programs (using Maildrop and Salesforce for Outlook) so I have written a trigger to copy the file to Content. Unfortunately, I can't seem to get it working for the body/file.  After insert, the attachment body referenced seems to be in some temp location and before insert the attachment has yet to be loaded so it can't find any body.

 

When I use before insert, I get the following error: Error: Required fields are missing: [Body]

 

When I use after insert, I get the following error: Error: Apex trigger NewAttachment caused an unexpected exception, contact your administrator: NewAttachment: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, java.io.FileNotFoundException: /tmp/bvf/cmp_5879646311450005283.def (No such file or directory): []: Trigger.NewAttachment: line 56, column 5

 

Any suggestions?

 

Here's my trigger:

 

trigger NewAttachment on Attachment (before insert) {

List<Attachment_Tracker__c> tracker = new List<Attachment_Tracker__c>();
List<ContentVersion> CV = new List<ContentVersion>();

for (Integer i = 0; i < Trigger.new.size(); i++) {
	String AttParent = Trigger.new[i].ParentId;
	String ContentDesc = '';
	String FileName = Trigger.new[i].Name;
	Blob BodyData = Trigger.new[i].Body;
		// Check to make sure there is a ParentID for the attachment and if records already exist for this Parent
		if(AttParent!=null) {
			String AttParSub = AttParent.substring(0,15);
			Map<String,ID> TrackMap = new Map<String,ID>();
			for (Attachment_Tracker__c c: [select Contact__c, id from Attachment_Tracker__c Where Contact__c =:AttParent] ) {
				TrackMap.put(c.Contact__c, c.id);
			}

			// Make sure the ParentID is a ContactID and it isn't already in the Attachment Tracker
			if(AttParent.startsWith('003')) {
				//Get the Contact Name
				Contact FullName = [SELECT Name, AccountID, Title FROM Contact WHERE Id = :AttParent];
				ContentDesc = FullName.Name+' ('+FullName.Title+' at '+FullName.AccountID+')';
				String ContName = FullName.Name;
				String ContAcct = FullName.AccountID;
				String ContTit = FullName.Title;
				// Get ID to set the Workspace to Resumes
				ContentWorkspace Workspace = [select id from ContentWorkspace where name = 'Resumes' limit 1];

				////////////////////////////////////////
				// First Copy Attachemnet to Content //
				//////////////////////////////////////
			    CV.add(new ContentVersion(
			    	FirstPublishLocationId = Workspace.id, 
			    	// Title = Trigger.new[i].Name,
			    	Contact__c = Trigger.new[i].ParentId,
			    	PathOnClient = Trigger.new[i].Name, 
			    	VersionData = BodyData
			    	) );

				////////////////////////////////////////
				// Now Update the Attachment Tracker //
				//////////////////////////////////////	
				if(!TrackMap.containsKey(AttParent)){
					tracker.add(new Attachment_Tracker__c(
		            Contact__c = Trigger.new[i].ParentId,
					File_Name__c = Trigger.new[i].Name,
					ContactName__c = ContName,
					Job_Title__c = ContTit,
					Company__c=ContAcct
	                ) ) ;
				}
	        }
		}
    insert tracker;
	insert CV;
	}
}