• Greg Coogan
  • NEWBIE
  • 174 Points
  • Member since 2015

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 56
    Replies
So im in a pickle. The magento developer is asking for my contact/account creation trigger to call their API and below is what i need to add ino my trigger but not sure where and how to get it to fire the request. This what I have currently in my trigger:
 
trigger MainContactTrigger on Contact (before update, before insert, after update, after insert) {
    DuplicateEmailFilter def = new DuplicateEmailFilter();
    Map<id,Contact> oldMap = trigger.oldMap;
    CreateAccountFromContact accountCreation = New CreateAccountFromContact();
    
    if(oldMap == null){
        oldMap = new Map<Id,Contact>();
    }
    if(Trigger.isBefore){
    // 
    // For the before creation we check if the contact is getting created by a real user then we use 
    // the Duplicate Email Filter to generate an error preventing the contact from being created.
    //
        if(!IntegrationUtils.isIntegrationUser()){
            def.processContacts(trigger.new, oldMap);
        }
        if( Trigger.isInsert && !IntegrationUtils.ignoreForAutoAccountUser() ) {
            accountCreation.ProcessBatchContactsWEmail(trigger.new,trigger.oldMap);
        }
        else if( Trigger.isInsert || Trigger.isUpdate ) {
            accountCreation.ProcessBatchContacts(trigger.new,trigger.oldMap);
        }
    }
    else{
    //
    // This is the After trigger - we just need to check if the email address is already
    // in use in the duplicate email filter. 
    // if it is being created by the integration user then in the DEF we flag the contct as having 
    // a duplicate. Leaving it up to the Salesforce Admin to clean it up.
    //
        if(IntegrationUtils.isIntegrationUser()){
            def.processContacts(trigger.new, oldMap);
        }
    }
    
}

and this is what i need to add into it somewhere to make this call to magento:
 
Salesforce to Magento Customer update endpoint url:
https://hallwinesm2-uat.smarterspecies.com/rest/V1/hall/salesforce/customer/sync
Content-Type:application/json
POST:
{
    "customer": {
        "firstname": "Maciej", 
        "lastname": "Garycki", 
        "email": "mgarycki+sf5333@gorillagroup.com", 
        "telephone": "6924609876", 
        "contact_sf_id": "1234567890", 
        "sfdc_updated_at": "182736", 
        "rms_account_no": "12345", 
        "customer_group_code": "GENERAL", 
        "revel_id": "", 
        "website_id": "1", 
        "store_id": "1", 
        "uuid": "", 
        "addresses": []
    }
}

Can anyone help me..

Thanks,

Ivan
I have a Process flow that starts with a Case but criteria such that it should only run when the associated Account is a particular RecordType.  I am getting error reports that  "The flow failed to access the value for myVariable_current.Account.RecordType.Name because it hasn't been set or assigned."  I don't understand how there can be an Account without a RecordType - even if the RecordType wasn't explicitly set when the Account was created - (such as having been converted from a Lead) the Account would still have the default RecordType.
A developer has the following trigger that fires after insert and creates a child Case whenever a new Case is created.
List<Case> childCases = new List<Case>();
for ( Case parent : Trigger.new )
Case child = new Case(Parentid = parent.id, Subject = parent -Subject);
childCases.add( child );
insert childCases;
What happens after the code block executes?

A.multiple child cases are created for each parent in trigger.new
B.Trigger enters infinite loop and eventually fails
C.Child case is created for each parent case in trigger.new
D.The trigger fails if subject field on parent is blank
I have a combobox in a Lightning Web Component.

Example value:
My Company Name (An Id)

Desired format:
My Company Name (An Id)

How would I make the company name bold, but not the text afterwards, the id in parentheses?
I've built a Lightning Web Component and need to write a Jest unit test class for it. A part of the component only renders when a tracked property, called it "showDesktopView" is true. The default value is false. For a Jest test case to pass, the section needs to render. Therefore, I need a method that will result in "showDesktopView" being set to true. It is set to true when the UI theme isn't mobile.

The property:
@track showDesktopView = false;

I've tried the below appproaches of setting the property, but they don't work.
const element = createElement('c-test', { is: testLWC });
element.showDesktopView = "true";  //Trial 1
element.showDesktopView = true;    //Trial 2
document.body.setAttribute('showDesktopView','true');  //Trial 3
document.body.appendChild(element);


return Promise.resolve().then(() => {
// My promise code
});

They don't seem to work since my Promise fails. I know my code in the Promise works because if I set the property "showDesktopView" to a default value of true, then it passes.

Does anyone know how to correctly set this property from a Jest unit test?
I am integrating with an external endpoint. The first step is to retrieve a token. When I first developed my solution, I did it all in Apex. However, I ran into an issue where my code would proceed to do a POST (my second step) before the token was recieved. As a result, I switched to using Javascript and its "Promises" on the Visualforce page that is run via custom button. In Apex, how would you replicate the Javascript Promises functionality that waits for a token to be received?
I have a custom Visualforce page and Controller that returns some records and related records. As part of the query, I put the related records in a List that is used in DataRow on the Visualforce page.

For writing my Test Class, I have code coverage, but cannot actually assert that I'm getting the correct data back. I beleive it is due to using of List of Lists in my Controller.

Here is code where I build the List of Lists in my Controller that has been anonymized:
public class MyController {
    public class Lists{
            public CustomCase__c someCase{get;set;}
            public List<CustomObjectB__c> somerecords{get;set;}
            public Lists(){
                this.someCase = new CustomCase__c();
                this.somerecords = new List<CustomObjectB__c>();
            }
     }

public List<Lists> lstList{get;set;}
I add records, including related records, to the lists in the following code:
 
public void getStuff(){

	query = 'Select Some Data'
		
	//Execute query
	transient List<CustomCase__c> lstCases = Database.query(query);
        
    //If any cases are returned, build lists of related records for each case returned. These lists are used on the Visualforce page.
        if(lstCases.size()>0){        
            for(CustomCase__c someCase:lstCases){
                Lists lst = new Lists();
                lst.someCase = someCase;
                if(someCase.somerecords__r.size() > 0){
                    lst.somerecords = someCase.somerecords__r;
                }
                lstList.add(lst);
			}
		}
}
When I access "lstList" in my test class, it returns  "MyController$Lists."

How can I access the list of related records in my Test Class? I want to assert that my related test record was returned by the query. In my example, I am referring to the "somerecords" list which represents records from an object that is related to the custom case object.
I need to do a HTTP POST where I set parameters in the headers. This will be triggered via custom button, but it cannot be a Javascript button. I cannot use PageReference for a redirect since it would b e a seperate operation from the POST. How can I get the POST operation to open/redirect to an external website as part of the POST operation?

I've reviewed existing documentation and also other forum posts, but none of them address my specific scenario.

I've got my Apex code written that is executed when the custom button loads a Visualforce page that passes data to the Apex code. I am just unable to get it to direct the user as part of the POST operation.
On my work laptop, my regular user doesn't have administrative permissions. To install Salesforce DX CLI, I needed admin permissions. Therefore, I used my secondary privelaged workstation user to "run-as" the installer. However, when I run command prompt under my regular user, the Salesforce DX CLI isn't accessable. I seem to only be able to access the Salesforce DX CLI when I run command prompt as administrator, which requires entering the credentials of my privelaged workstation user. Is this expected? Is there any way to access the Salesforce DX CLI when not running command prompt with administrator permissions? 
I have some Apex that generates an XML file and PDF file, inserts them into the Document object. How can we access it via API? The plan is to use Python. I've done some research and it appears XML could be handled, but I am not sure about the PDF.
I've been looking for a solution to allow users to export dashboards as a PDF. I tried a POC with embedding a dashboard with on a VF page, but no luck. I've seen guides on how to embed specific components of a dashboard using the image servlet, but I'm looking for the whole dashboard. Rendering as PDF didn't work when I tried to use the ID of the dashboard in an iFrame.

The ideal solution would be a button to export the dashboard when viewing the dashboard. However, I cannot add custom buttons to a the dashboard page. Therefore, I have thought of this:
1. Visualforce page with a dropdown of dashboards
2. Users choose a dashboard, and click a button on the Visualforce page that triggers a download of that dashboard

Since I had no success with the dashboard in iFrame, I am wondering if this is even possible. How would I accomplish this?
I have written a custom controller and Visualforce page that displays records from a custom object, and related records, in a few HTML tables. I have a checkbox on the page and a Save button to display the refined results. Do I need to write a function that returns a modified list of records, basically copying what is in my controller's main class to a "PageReference save()" class? Ideally, the button would result in the controller running again with the updated value of the checkbox. I've seen examples but having trouble. Please help.
Please help! We have Salesforce Shield. The Transaction Security feature automatically creates two Apex Classes that are used for Transaction Security Policies. They are:
  1. ConcurrentSessionsPolicyCondition
  2. DataLoaderLeadExportCondition
These are two of the three Apex Classes I have in a new org. I am trying to deploy the test class of the third Apex Class, which is a controller I wrote, but forget to deploy the Test Class with it.

Those two Apex Classes created by Salesforce Shield do not have Test Classes created with them. Why is this? It results in a very low code coverage and I cannot deploy to our Production org as a result.
I am trying to run a query that has multiple conditions in the WHERE clause. If I reduce it to a single condition by removing two of the other conditions I need, the query works. I have three conditions and I have tried a query with each individual condition. They all work. However, when they are combined using AND, I receive an error. I have tried all different combinations of using parentheses to see if it makes a difference, but no luck. To provide an example, I have replaced the field names,object names, and values with fake names. I am using the developer console's query editor at this time.

Example:
SELECT SUM(CustomField1) FROM CustomObject__c WHERE CustomField1 = 'Value1' AND CustomField2 = 'Value2' AND CustomField3 != 'Value3'

I have referenced the SOQL documentation but no luck. Do you see anything wrong with my query?
We want to do roll-up calculations in Python and inserting the values using the API, instead of letting Salesforce do the work. In most cases, there is a master-detail relationship between the parent and child object, but there will also be a case of only a lookup field between Opportuntiy and a custom object. What is the best method to do this? It would be nice if I could sum up the field to calculate with a single API call.
I am querying against the ContentNote object using the Developer Console. I am using the administrator account to query, which has the Modify All Data permission. However, I return no results from that table even though my users have many Notes. How can I query the IDs of everyone's notes? Are they hidden from me? The query did return a few records before I deleted my Notes, so I know the query is correct.

Query:
SELECT Id FROM ContentNote
All documentation and articles I have found create a new test user to be used with the RunAs method in a Test Class. How would I run as an existing user, such as an "Integration User" we have? I don't want to create a new user in the Test Class.
I am developing a Lightning Component based off the tutorial for the Account List Lightning Component. In the Apex Controller, I want to modify the query to only select records related to the currently viewed record. I tried using ApexPages.currentPage().getParameters().get('id') but it didn't work. The user would be viewing the details of a particular Event when this code would run. How can I get the current Event record ID in the Apex Controller of a Lightning Component?

Here is the turotial I am referring to:https://developer.salesforce.com/trailhead/project/slds-lightning-components-workshop/slds-lc-6
Hi, I am new to Salesforce.

I have this Email Alert setup as so:

User-added image

How would I create a workflow rule that will fire whenever an EVENT is created?

This is the step I am stuck on
I have a combobox in a Lightning Web Component.

Example value:
My Company Name (An Id)

Desired format:
My Company Name (An Id)

How would I make the company name bold, but not the text afterwards, the id in parentheses?
I've built a Lightning Web Component and need to write a Jest unit test class for it. A part of the component only renders when a tracked property, called it "showDesktopView" is true. The default value is false. For a Jest test case to pass, the section needs to render. Therefore, I need a method that will result in "showDesktopView" being set to true. It is set to true when the UI theme isn't mobile.

The property:
@track showDesktopView = false;

I've tried the below appproaches of setting the property, but they don't work.
const element = createElement('c-test', { is: testLWC });
element.showDesktopView = "true";  //Trial 1
element.showDesktopView = true;    //Trial 2
document.body.setAttribute('showDesktopView','true');  //Trial 3
document.body.appendChild(element);


return Promise.resolve().then(() => {
// My promise code
});

They don't seem to work since my Promise fails. I know my code in the Promise works because if I set the property "showDesktopView" to a default value of true, then it passes.

Does anyone know how to correctly set this property from a Jest unit test?
Hi.

Happy about finally delivering option to get recordId by developer name, see relase info https://releasenotes.docs.salesforce.com/en-us/summer18/release-notes/rn_apex_developer_name.htm I wanted to use it. It works perfectly on Anonymous execution, however if used in apex class it is not possible to save due to method does not exists error.
Id devRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('PersonAccount').getRecordTypeId();
System.debug(devRecordTypeId);
In anonymous execution it returns a value in debug. Using in apex class gives an error:
Method does not exist or incorrect signature: void getRecordTypeInfosByDeveloperName() from the type Schema.DescribeSObjectResult
Do we have SF peoples here? Can you please fix it.
 
I am integrating with an external endpoint. The first step is to retrieve a token. When I first developed my solution, I did it all in Apex. However, I ran into an issue where my code would proceed to do a POST (my second step) before the token was recieved. As a result, I switched to using Javascript and its "Promises" on the Visualforce page that is run via custom button. In Apex, how would you replicate the Javascript Promises functionality that waits for a token to be received?
I have created a save button using js lightning controller, but am running into an issue where a user is able to click the Save button multiple times, creating multiple duplication of a new record. I disabled the popup window that confirms the save record (line 16 in code below). Is their a way to disable the save button after the user clicks on it once, then as the record uploads and saves into Salesforce and the table refreshes, have the save button refresh in order to re-appear? 
 
({
    doInit: function(component, event, helper) {
        helper.createObjectData(component, event);
    },
    Save: function(component, event, helper) {
        if (helper.validateRequired(component, event)) {
            var action = component.get("c.saveContacts");
            action.setParams({
                "ListContact": component.get("v.contactList")
            });
            action.setCallback(this, function(response) {
                var state = response.getState();
                if (state === "SUCCESS") {
                    component.set("v.contactList", []);
                    helper.createObjectData(component, event);
            //        alert('Contact Record Saved');                    
                }
            });
            $A.enqueueAction(action);
        }
    },
    addNewRow: function(component, event, helper) {
        helper.createObjectData(component, event);
    },
    removeDeletedRow: function(component, event, helper) {
        var index = event.getParam("indexVar");
        var AllRowsList = component.get("v.contactList");
        AllRowsList.splice(index, 1);
        component.set("v.contactList", AllRowsList);
    },
})

 
My team has been researching the ability for Eloqua to add logic to only pass fields from Eloqua to Salesforce if they are not blank or the target SFDC field is not blank.  Unfortunately, we concluded it is not possible from the Eloqua end to do this. This could significantly impact the contact record if we send lead activity data back for a known SFDC contact, as we don’t write the existing SFDC data to our contact record since we can’t do prioritized overwrite rules in Eloqua.
 
Does anyone know if there is a way for Salesforce to manage this for the incoming data source? Is it possible to set logic on designated lead and contact fields to only accept Eloqua data if it is not blank, and for specific fields only if SFDC is blank?
 
So im in a pickle. The magento developer is asking for my contact/account creation trigger to call their API and below is what i need to add ino my trigger but not sure where and how to get it to fire the request. This what I have currently in my trigger:
 
trigger MainContactTrigger on Contact (before update, before insert, after update, after insert) {
    DuplicateEmailFilter def = new DuplicateEmailFilter();
    Map<id,Contact> oldMap = trigger.oldMap;
    CreateAccountFromContact accountCreation = New CreateAccountFromContact();
    
    if(oldMap == null){
        oldMap = new Map<Id,Contact>();
    }
    if(Trigger.isBefore){
    // 
    // For the before creation we check if the contact is getting created by a real user then we use 
    // the Duplicate Email Filter to generate an error preventing the contact from being created.
    //
        if(!IntegrationUtils.isIntegrationUser()){
            def.processContacts(trigger.new, oldMap);
        }
        if( Trigger.isInsert && !IntegrationUtils.ignoreForAutoAccountUser() ) {
            accountCreation.ProcessBatchContactsWEmail(trigger.new,trigger.oldMap);
        }
        else if( Trigger.isInsert || Trigger.isUpdate ) {
            accountCreation.ProcessBatchContacts(trigger.new,trigger.oldMap);
        }
    }
    else{
    //
    // This is the After trigger - we just need to check if the email address is already
    // in use in the duplicate email filter. 
    // if it is being created by the integration user then in the DEF we flag the contct as having 
    // a duplicate. Leaving it up to the Salesforce Admin to clean it up.
    //
        if(IntegrationUtils.isIntegrationUser()){
            def.processContacts(trigger.new, oldMap);
        }
    }
    
}

and this is what i need to add into it somewhere to make this call to magento:
 
Salesforce to Magento Customer update endpoint url:
https://hallwinesm2-uat.smarterspecies.com/rest/V1/hall/salesforce/customer/sync
Content-Type:application/json
POST:
{
    "customer": {
        "firstname": "Maciej", 
        "lastname": "Garycki", 
        "email": "mgarycki+sf5333@gorillagroup.com", 
        "telephone": "6924609876", 
        "contact_sf_id": "1234567890", 
        "sfdc_updated_at": "182736", 
        "rms_account_no": "12345", 
        "customer_group_code": "GENERAL", 
        "revel_id": "", 
        "website_id": "1", 
        "store_id": "1", 
        "uuid": "", 
        "addresses": []
    }
}

Can anyone help me..

Thanks,

Ivan
Please help! We have Salesforce Shield. The Transaction Security feature automatically creates two Apex Classes that are used for Transaction Security Policies. They are:
  1. ConcurrentSessionsPolicyCondition
  2. DataLoaderLeadExportCondition
These are two of the three Apex Classes I have in a new org. I am trying to deploy the test class of the third Apex Class, which is a controller I wrote, but forget to deploy the Test Class with it.

Those two Apex Classes created by Salesforce Shield do not have Test Classes created with them. Why is this? It results in a very low code coverage and I cannot deploy to our Production org as a result.