• W Chad Smith
  • NEWBIE
  • 50 Points
  • Member since 2012
  • Salesforce.com Technical Architect


  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 3
    Questions
  • 10
    Replies
I am trying to get a LWC to work as a headless quick action.  Everything isi working fine, but I'm un sure of how to call my Apex method with a parameter.  Here's the JS
 
import { LightningElement, api } from 'lwc';
import doAssignment from '@salesforce/apex/CaseAssignment.doAssignment';
export default class caseSubmitToManagementLWC extends LightningElement {

    isExecuting = false;    
    
    @api async invoke() {
        if (this.isExecuting) {
            return;
        }  
        console.log(this.recordId);
        console.log('Execution Start');
        this.isExecuting = true;
        await this.sleep(2000);
        this.isExecuting = false;
        console.log('Execution Stop');
    }  
    
    sleep(ms) {
        return new Promise((resolve) => setTimeout(resolve, ms));
    }

    
}

 

I have a class that is this:

 

public with sharing class Constants {
    public static final String NOZZLE = 'Nozzle'; 
    public static final String MANIFOLD = 'Manifold';
    public static final String INLET = 'Inlet';

 

 

I am attempting to write test code for it, test class looks like this:

 

@isTest
private class Test_Constants {

    static testMethod void myUnitTest() {
		Constants con = new Constants();
		System.assertEquals(Constants.ACTUATOR_COST,Constants.ACTUATOR_COST);

 For some reason I'm getting 0 test coverage.  For the Systerm.assert, I tried con. rather than constants. but got an error... Added in a System.Debug in the test as well and the string value for the variable is getting pulled, not sure why Salesforce is reporting 0 coverage.

I have a trigger on Task, which should look at the WhatID, grab the contact that's associated with and then populate the task WhoID for that contact.  What's strange is that the task field updates related to description and Contact_ID_Test__c are working just fine and the ID is correct, so the maps, etc. are all OK.  It just seemas as though SFDC isn't letting me update the WhoID Field.  Here's the code, and thanks in advance!

 

 

trigger trBeforeInsertBeforeUpdateTask on Task (before insert, before update, after insert, after update) {

	//Set of WhoIDs being updated
	set<ID> whoIDs = new set<ID>();
	//Set of What IDs being updated
	set<ID> whatIDs = new set<ID>();
	//Map of Contact IDs and Contacts
	map<ID,Contact> contactMap = new map<ID,Contact>();
	//Map of Product Interest IDs
	map<ID,Product_Interest__c> productInterestMap = new map<ID,Product_Interest__c>();
	//List of tasks for after update
	list<Task> tasksToUpdate = new list<Task>();
	
	//Get all of the whoIDs of the tasks being inserted/updated
	for (task t : trigger.new) {
		whoIDs.add(t.whoid);
		whatIDs.add(t.whatid);
	}
	//Populate contactMap with the contact IDs and contact record
	for (contact c : [select id, Extension__c from contact where id in : whoIDs]) {
		contactMap.put(c.id,c);
	}
	//Populate productInterestMap with the IDs from the Task Record
	for (Product_Interest__c pi : [select id, Contact__c from Product_Interest__c where id in : whatIDs]) {
		productInterestMap.put(pi.id,pi);
	} 
	
	if (trigger.isBefore) {
		for (task t : trigger.new) {
			if (contactMap.containsKey(t.whoid)) {
				t.ext__c = contactMap.get(t.whoID).Extension__c;
			}	
			
			if (t.WhoId == null & productInterestMap.containsKey(t.whatid)) {
				string contactID = productInterestMap.get(t.whatid).Contact__c;
				contactID = contactID.substring(0,15);
				id testid = contactID;
				t.WhoId = testid;
				t.Contact_ID_Test__c = contactID;
				t.Description = date.today() + ':' + productInterestMap.get(t.whatid).Contact__c;
				System.Debug(':::: T What ID:::' + t.whatid);
				System.Debug(':::t.WhoID::::' + t.WhoID);
				System.Debug('::ContactID:::' +  productInterestMap.get(t.whatid).Contact__c);
			}				
		}
	}
}

 

Hi All, 
 
I am writing a trigger on ContentVersion in a Scratch Org and I have the below code working in a developer org, but it won't save in a Scratch org and I am getting the error "Variable does not exist: ContentDocumentId". The Trigger code is as follows:
trigger ContentVersionTrigger on ContentVersion (after insert) {
    Set<Id> contentDocumentIdSet = new Set<Id>();

    for(ContentVersion cv : Trigger.New) {
        contentDocumentIdSet.add(cv.ContentDocumentId);
    }
}
Also, if I comment out the code contentDocumentIdSet.add(cv.ContentDocumentId);

I get the following error:

"Invalid loop variable type expected ContentVersion was ContentVersion"

Does anyone know why?
User-added image
Not sure whats wrong with my New Account page record components. I think everything is as per the challenge. can you please tell me what am I doing wrong here ? 

I have a class that is this:

 

public with sharing class Constants {
    public static final String NOZZLE = 'Nozzle'; 
    public static final String MANIFOLD = 'Manifold';
    public static final String INLET = 'Inlet';

 

 

I am attempting to write test code for it, test class looks like this:

 

@isTest
private class Test_Constants {

    static testMethod void myUnitTest() {
		Constants con = new Constants();
		System.assertEquals(Constants.ACTUATOR_COST,Constants.ACTUATOR_COST);

 For some reason I'm getting 0 test coverage.  For the Systerm.assert, I tried con. rather than constants. but got an error... Added in a System.Debug in the test as well and the string value for the variable is getting pulled, not sure why Salesforce is reporting 0 coverage.

I have a trigger on Task, which should look at the WhatID, grab the contact that's associated with and then populate the task WhoID for that contact.  What's strange is that the task field updates related to description and Contact_ID_Test__c are working just fine and the ID is correct, so the maps, etc. are all OK.  It just seemas as though SFDC isn't letting me update the WhoID Field.  Here's the code, and thanks in advance!

 

 

trigger trBeforeInsertBeforeUpdateTask on Task (before insert, before update, after insert, after update) {

	//Set of WhoIDs being updated
	set<ID> whoIDs = new set<ID>();
	//Set of What IDs being updated
	set<ID> whatIDs = new set<ID>();
	//Map of Contact IDs and Contacts
	map<ID,Contact> contactMap = new map<ID,Contact>();
	//Map of Product Interest IDs
	map<ID,Product_Interest__c> productInterestMap = new map<ID,Product_Interest__c>();
	//List of tasks for after update
	list<Task> tasksToUpdate = new list<Task>();
	
	//Get all of the whoIDs of the tasks being inserted/updated
	for (task t : trigger.new) {
		whoIDs.add(t.whoid);
		whatIDs.add(t.whatid);
	}
	//Populate contactMap with the contact IDs and contact record
	for (contact c : [select id, Extension__c from contact where id in : whoIDs]) {
		contactMap.put(c.id,c);
	}
	//Populate productInterestMap with the IDs from the Task Record
	for (Product_Interest__c pi : [select id, Contact__c from Product_Interest__c where id in : whatIDs]) {
		productInterestMap.put(pi.id,pi);
	} 
	
	if (trigger.isBefore) {
		for (task t : trigger.new) {
			if (contactMap.containsKey(t.whoid)) {
				t.ext__c = contactMap.get(t.whoID).Extension__c;
			}	
			
			if (t.WhoId == null & productInterestMap.containsKey(t.whatid)) {
				string contactID = productInterestMap.get(t.whatid).Contact__c;
				contactID = contactID.substring(0,15);
				id testid = contactID;
				t.WhoId = testid;
				t.Contact_ID_Test__c = contactID;
				t.Description = date.today() + ':' + productInterestMap.get(t.whatid).Contact__c;
				System.Debug(':::: T What ID:::' + t.whatid);
				System.Debug(':::t.WhoID::::' + t.WhoID);
				System.Debug('::ContactID:::' +  productInterestMap.get(t.whatid).Contact__c);
			}				
		}
	}
}

 

Hi everybody. We have a trigger on task object which works before insert and changes WhoId value like this:

trigger x on Task (before insert ) {
	Set<String> taskIds = new Set<String> ();
	for(Task t : trigger.new)
		taskIds.add(t.WhatId);
	Map<id, Custom_Object__c> mas = new Map<id, Custom_Object__c>([Select Id, Account__r.PersonContactId From Custom_Object__c where Account__r.IsPersonAccount = true and Id in : taskIds]);
	for(Task t : trigger.new) {
		Custom_Object__c a = mas.get(t.WhatId);
		if(a == null) continue;
		t.WhoId = a.Account__r.PersonContactId;
	}
}

 

When I create a task record. The created tasks whoId field is always NULL. When I check the debug logs, I can clearly see this trigger works and assings a new whoid value. But somehow in the end, it always returns to null and there are no errors, or warnings...

 

When I run someting like update new Task(ID='XXX', WhoID='YYY'); (where the values of XXX is a Task ID and YYY is a PersonAccount Contact ID) from the developer console, I can see that WhoID value is changing.

 

We are using Person Accounts. The Custom_Object__c has a lookup field for Account object named Account__c. 

 

What do you think, what is the problem of this code?

  • November 18, 2012
  • Like
  • 0

I have had the audit fields (created by, created dates, last modified by, etc) opened by sfdc, and need to see if there is a way to populate these via an update rather than an insert. Through the data loader, they are only available via insert. Is this a data loader limitation or a salesforce limitation? We also have DB Amp, and do not have access on an update either. Anyway around this?

User-added image
Not sure whats wrong with my New Account page record components. I think everything is as per the challenge. can you please tell me what am I doing wrong here ?