• Emily Johnson 23
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 7
    Replies
Does anyone have an example of cloning a record using jsforce? I have attempted tihs a few different ways. The (very limited) resources I've found refer to using _.clone(record) but I am getting a circular reference error so I'm sure I am missing something.

if (lines.length) {
var newRecords = [];
lines.forEach(function(line) {
var record = _.clone(line);
delete record.Id;
newRecords.push({
record
});
});
if (newRecords.length) {
return conn.sobject('SBQQ__QuoteLine__c').create(newRecords, function(err, ret) {
alert('after new insert -->'+JSON.stringify(ret));
});
}
}
return Promise.resolve();
}
I'm using e.force:navigateToURL for clickable links in my lightning component. I have tried several different ways of creating this url. I need it to open the links in a new tab so that the original window remains open. 

When the links are clicked, it opens the URL in a new window (as expected), but it's also changing the original window's URL. How do I prevent this from happening?

Here is my function:
 
handleClick : function(component, event, helper) {  
        var baseURL = component.get("v.cbaseURL");
        var viewRecordEvent = $A.get("e.force:navigateToURL");
        viewRecordEvent.setParams({             
             "url": window.open(baseURL+'/'+ event.target.id,'_blank')              
       });
       viewRecordEvent.fire();
    }
Here are some screenshots showing the behavior.

Lightning component with clickable link:
User-added image

New tab that is opened:
User-added image

Original tab (after clicking link):
User-added image

I'm using a datatable in a lightning (aura) component. Since the columns don't allow for notation to get the relationship_field__r.QualifiedApiName I am trying to flatten the data the way you would with a lookup field on an object (as referenced here: https://salesforce.stackexchange.com/questions/200761/parent-field-in-lightning-datatable)

However it is not working and my column is still displaying blank.

Has anyone had success with a similar requirement displaying custom metadata relationship field names in a datatable?

Does anyone have an example of cloning a record using jsforce? I have attempted tihs a few different ways. The (very limited) resources I've found refer to using _.clone(record) but I am getting a circular reference error so I'm sure I am missing something.

if (lines.length) {
var newRecords = [];
lines.forEach(function(line) {
var record = _.clone(line);
delete record.Id;
newRecords.push({
record
});
});
if (newRecords.length) {
return conn.sobject('SBQQ__QuoteLine__c').create(newRecords, function(err, ret) {
alert('after new insert -->'+JSON.stringify(ret));
});
}
}
return Promise.resolve();
}
I'm using e.force:navigateToURL for clickable links in my lightning component. I have tried several different ways of creating this url. I need it to open the links in a new tab so that the original window remains open. 

When the links are clicked, it opens the URL in a new window (as expected), but it's also changing the original window's URL. How do I prevent this from happening?

Here is my function:
 
handleClick : function(component, event, helper) {  
        var baseURL = component.get("v.cbaseURL");
        var viewRecordEvent = $A.get("e.force:navigateToURL");
        viewRecordEvent.setParams({             
             "url": window.open(baseURL+'/'+ event.target.id,'_blank')              
       });
       viewRecordEvent.fire();
    }
Here are some screenshots showing the behavior.

Lightning component with clickable link:
User-added image

New tab that is opened:
User-added image

Original tab (after clicking link):
User-added image

I'm using a datatable in a lightning (aura) component. Since the columns don't allow for notation to get the relationship_field__r.QualifiedApiName I am trying to flatten the data the way you would with a lookup field on an object (as referenced here: https://salesforce.stackexchange.com/questions/200761/parent-field-in-lightning-datatable)

However it is not working and my column is still displaying blank.

Has anyone had success with a similar requirement displaying custom metadata relationship field names in a datatable?

Hi have a lightning component datatable that is populated by a query with a subquery in it. I need the second column to be poulated with a value from the subquery but I can't seem to figure out how to set the field name for the the subquery field. 

Screen shot: (RPF Con should map to sub query field.
User-added imageApex Class
public class RFPOppListController {

        @AuraEnabled
    public static List <Opportunity> fetchOpps (String oppId) {
        //Qyery 10 
        List<Opportunity> oppList = [SELECT Opportunity.Name, (select Contact__r.Name from Opportunity_Contact_Roles__r where Contact_roles__c = 'RFP consultant') FROM Opportunity];
        //return lis
        return oppList;
    }
}

Component:
<aura:component controller="RFPOppListController" access="global" implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId">

    <aura:attribute type="Opportunity[]" name="oppList"/>
    <aura:attribute name="mycolumns" type="List"/>
    <aura:attribute name="updatedRecord" type="Object[]" />


     
    <aura:handler name="init" value="{!this}" action="{!c.fetchOPPS}"/>
     
    <lightning:datatable aura:id="oppsDataTable"
                         data="{! v.oppList }"
                         columns="{! v.mycolumns }"
                         keyField="Id"
                         hideCheckboxColumn="true"
                         onsave ="{!c.onSave}"
                         />
     
</aura:component>

Controller
({
    fetchOPPS : function(component, event, helper) {
        helper.fetchOPPSHelper(component, event, helper);    

    }
})
Helper
({
    fetchOPPSHelper : function(component, event, helper) {
        component.set('v.mycolumns', [
            {label: 'Opp Name', fieldName: 'Name', editable:'true', sortable:'true', type: 'text'},          
            {label: 'RFP Con', fieldName: 'Opportunity_Contact_Roles__r.Contact__r.Name', editable:'true', sortable:'true', type: 'date'}   
            ]);
        debugger;
        var action = component.get("c.fetchOpps");      
        var operID = component.get("v.recordId");
        console.log("operID" + operID);
        action.setParams({
            oppId:operID
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.oppList", response.getReturnValue());
            }
        }); 
        $A.enqueueAction(action);
    }
})


BTW, here is a debugger screenshot of of the value I am trying to display:
User-added image
public class AnimalsCallouts {
    public static HttpResponse makeGetCallout() {
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals');
        request.setMethod('GET');
        HttpResponse response = http.send(request);
        // If the request is successful, parse the JSON response.
        if (response.getStatusCode() == 200) {
            // Deserializes the JSON string into collections of primitive data types.
            Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
            // Cast the values in the 'animals' key as a list
            List<Object> animals = (List<Object>) results.get('animals');
            System.debug('Received the following animals:');
            for (Object animal: animals) {
                System.debug(animal);
            }
        }
        return response;
    }
    public static HttpResponse makePostCallout() {
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals');
        request.setMethod('POST');
        request.setHeader('Content-Type', 'application/json;charset=UTF-8');
        request.setBody('{"name":"mighty moose"}');
        HttpResponse response = http.send(request);
        // Parse the JSON response
        if (response.getStatusCode() != 201) {
            System.debug('The status code returned was not expected: ' +
                response.getStatusCode() + ' ' + response.getStatus());
        } else {
            System.debug(response.getBody());
        }
        return response;
    }        
}
HOW TO CREATE A VISUALFORCE PAGE FOR THIS APEX CLASS??? WITH TWO BUTTONS OF POST AND GET????
THANKS >>>
 
I have a lightning component that implements lightning:actionOverride how do I get the recordId of the parent when the action is triggered from a related list?