• ethanone
  • NEWBIE
  • 174 Points
  • Member since 2009

  • Chatter
    Feed
  • 5
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 72
    Questions
  • 85
    Replies
I have a custom object Requests__c and each time the request status changes, i have a process builder that creates a custom related object called Request_Activity__c. The purpose of which is to capture the activity on the request (and generate reports, metrics, etc).

Whenever the Request Activity is created, a Feed item is created on the Request. I do not want a feed item for Request Activities, however I cannot turn off related feed tracking because i need it for notes and other related items.

To solve this, I created a Flow, that deletes the Request Activity Feed Item record, by selecting the Feed Item by the parent Id (Request Activity). Unfortunately it only runs for me. I cannot get it to run for other users. I get the error "FeedItem requires a filter by Id." How can I resolve this?
I've got a simple LWC for a rich text box. The default size is only a few lines and I'd like to make it bigger.
Here is the HTML for lwc:
<template>
<lightning-input-rich-text value={rtval} onchange={handleChange}>
</lightning-input-rich-text>
</template>
How do I make the text box have height:14em?
 
I'm trying to create child records when a user checks a checkbox widget (and delte when unchecked). I've tried to put a createRecord() and deleteRecord() in the change handler for the checkbox, but i get "Uncaught (in promise) TypeError: Cannot read property 'dispatchEvent' of undefined"

I've also tried to put the createRecord in a separate button, which will create the record, but will also create duplicates and requires looking for multiple changes rather than reacting to each click like I might in the checkbox handler.

Below is the checkbox change handler. I'm getting errors on the dispatch event (misusing the this. perhaps?) removing this.dispatchEvent() eliminates the error, but records are neither created nor deleted and I don't know why. Please help me better understand creating and deleteing records. Thanks in advance.
handleChange(e) {
    const beforeChangeList = this.selectedOptions;
    const afterChangelist = e.detail.value;
    const aRecId = this.recordId;
    this.selectedOptions = e.detail.value;

    console.log("before >>>> " + beforeChangeList);
    console.log("after >>>> " + afterChangelist);

    // Compare list for adds
    afterChangelist.forEach(function(element) {
      if (beforeChangeList.includes(element)) {
        console.log(">>>>, do nothing for " + element);
      } else {
        console.log(">>>>, add " + aRecId + " - " + element);
        const fields = { DealID: aRecId, Agent_Order__c: 1, Agent__c: element };
        const recordInput = { apiName: COMMISSION_OBJECT.objectApiName, fields };
        console.log(">>>> add " + JSON.stringify(recordInput));
        createRecord(recordInput)
          .then(lda_commission__c => {
            this.dispatchEvent(
              new ShowToastEvent({
                title: "Success",
                message: "Commission added",
                variant: "success"
              })
            );
            console.log(">>>> record created");
          })
          .catch(error => {
            this.dispatchEvent(
              new ShowToastEvent({
                title: "Error creating record",
                message: reduceErrors(error).join(", "),
                variant: "error"
              })
            );
            console.log(">>>> record not created." + reduceErrors(error).join(", "));
          });
      }
    });

    // Compare list for deletes
    beforeChangeList.forEach(function(element) {
      if (afterChangelist.includes(element)) {
        console.log(">>>>, do nothing for " + element);
      } else {
        console.log(">>>>, drop " + element);
        deleteRecord(element)
          .then(() => {
            this.dispatchEvent(
              new ShowToastEvent({
                title: "Success",
                message: "Commission is deleted",
                variant: "success"
              })
            );
            console.log(">>>> comm deleted");
          })
          .catch(error => {
            this.dispatchEvent(
              new ShowToastEvent({
                title: "Error while deleting commission",
                message: error.message,
                variant: "error"
              })
            );
            console.log(">>>> com not deleted." + error.message);
          });
      }
    });
  }

 
I’m trying to build a LWC that displays a checkbox group created from the list of active users in the same sales market as the current user.

Html file (based on component reference):
<template>
        <lightning-checkbox-group name="Checkbox Group"
                                label="Select a User"
                                options={comms}
                                value={value}
                                onchange={handleChange}>
        </lightning-checkbox-group>
        <p>Selected Values are: {selectedValues}</p>
</template>
js file:
import { LightningElement, api, track, wire } from "lwc";
import getMktUsers from "@salesforce/apex/Top100.getMktUsers";
import getCommissions from "@salesforce/apex/Top100.getCommissions";
import Id from "@salesforce/user/Id";

let url_string = window.location.href;
let url = new URL(url_string);
let rid = url.searchParams.get("Id");

export default class Top100 extends LightningElement {
  @api recordId;
  @api objectApiName;
  @api userId;
  @track value = ["Option1"];
  userId = Id;
  recordId = rid;

  @wire(getMktUsers, { usrId: "$userId" }) MktUsers;
  @wire(getCommissions, { rid: "$recordId" }) selectedVals;

  objectApiName = "lda_Opportunity__c";

  get comms() {
    return [{ label: "Ross", value: "Option1" }, { label: "Rachel", value: "Option2" }];
  }

  get selectedValues() {
    return this.value.join(",");
  }

  handleChange(e) {
    this.value = e.detail.value;
  }
}
Apex file:
public with sharing class Top100 {
    @AuraEnabled(cacheable=true)
    public static List<Account> getMktUsers(Id usrId) {
        User ThisUser = [SELECT Id, Name, Office__c FROM User WHERE Id = :usrId LIMIT 1];
        List<User> MarketUsers = [SELECT Id FROM User WHERE Office__c = :ThisUser.Office__c and IsActive = True];
        //Users have matching Person accounts because some opportunities involve external sales people.
        return [SELECT Id, Name, FirstName, LastName FROM Account WHERE UserLookup__c IN :MarketUsers];
    }

    @AuraEnabled(cacheable=true)
    public static List<String> getCommissions(Id rid){
        List<String> values = new List<String>();
        for (lda_Commission__c comm : [SELECT Agent__c, Agent__r.Name FROM lda_Commission__c WHERE DealId__c = :rid]){
            values.add(comm.Agent__c);
        }
        System.debug('Values: ' + values);
        return values;
    }
}
1) How do I take the results of my Apex function and format it for the checkbox group options parameter?
2) How do I take the results of my getCommissions Apex function and format it for the checkbox group value parameter?



 
I'm trying to display the list of acitve users in the same branch office as the logged in user in a LWC.
I have an apex class that looks like this:
@AuraEnabled(cacheable=true)
    public static List<User> getMktUsers(String usrId) {
        User ThisUser = [SELECT Id, Name, Office__c FROM User WHERE Id = :usrId LIMIT 1];
        return [SELECT Id, Name FROM User WHERE Office__c = :ThisUser.Office__c and IsActive = True];
    }
I have refer to it in my LWC js file like this:
import { LightningElement, api, track, wire } from "lwc";
import getMktUsers from "@salesforce/apex/Top100.getMktUsers";
import Id from "@salesforce/user/Id";

export default class Top100 extends LightningElement {
  @wire(getMktUsers, { usrId: { Id } }) wiredUsers;
}
I call it in my html file like this:
<ul class="slds-list_ordered">
            <template for:each={wiredUsers.data} for:item="wuser">
                <li key={wuser.Id}>
                    {wuser.Name}
                </li>
            </template>
        </ul>
I'm able to get lists of users to appear if I hard code the office name, but when I try to pass in the Id to determie the current user's office, i get nothing appearing. I do not know how to debug this. Can anyone help?
 
I'm trying to rewrite some older visualforce pages that will work for both my lightning and classic users. I'd prefer using LWC since it is the recommended approach to new projects and much less complicated. However it does not work with Lightning out. Now that LWC is open-sourced, could I write an opensource LWC component and present it on both a lighting record page for lightning users as well as a VF page for classic users?
I have a flow called from a VFP that needs to utilize the Upload Files component in the flow. Since this component only works if the flow runs in Lightning Runtime, this has been enabled in our org. It turns out though, that any flow called from a VFP will by default render in Classic, EVEN IF Lightning Runtime is enabled.

I followed the directions in this document (https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_flows_lightningruntime.htm) to create a Lightning Component extending Lightning Out with a dependency on lighting:flow. Then I updated the VFP to call this component and launch the flow. 

This did result in the flow seemingly to run in Lightning Runtime vs Classic (at least visually it did). Unfortunately, the upload file component still does not work, even with this solution in place. 

Does anyone have any idea how I can get this file upload component to function to work when called from a VFP in Lightning Runtime? I'm stumped. 

Code as its implemented now is below - I haven't set any of the finish behavior or outputs yet. 
<aura:application access="global" extends="ltng:outApp" >
    <aura:dependency resource="lightning:flow"/>
</aura:application>
<apex:page standardController="Stipulations__c" recordSetVar="stipulations">
   <html>
      <head>
         <apex:includeLightning />
      </head>
      <body class="slds-scope">
         <div id="flowContainer" />
         <script>
             var statusChange = function (event) {
               if(event.getParam("status") === "FINISHED") {
                  // Control what happens when the interview finishes
 
                  var outputVariables = event.getParam("outputVariables");
                  var key;
                  for(key in outputVariables) {
                     if(outputVariables[key].name === "myOutput") {
                        // Do something with an output variable
                     }
                  }
               }
            };            $Lightning.use("c:LightningRuntime", function() {
               // Create the flow component and set the onstatuschange attribute
               $Lightning.createComponent("lightning:flow", {"onstatuschange":statusChange},
                  "flowContainer",
                  function (component) {
                     // Set the input variables
                     var inputVariables = [
                        {
                           name : 'inputOpptyId',
                           type : 'String',
                           value : "{!$CurrentPage.parameters.Id}"
                        }
                     ];
                     
                     // Start an interview in the flowContainer div, and 
                     // initializes the input variables.
                     component.startFlow("Stipulations_Submit_Documentation", inputVariables);
                  }
               );
            });
         </script>
      </body>
   </html>
</apex:page>


 
I used to use the Eclipse Force IDE and I'm switching to VSCode/SFDX. When creating a project in Force IDE, you could specify retreiving "Apex, Lightning, and Visualforce (classes, triggers, test suites, LIghtinging component bundles, pages, Visualforce comonents, and static resources)" 
It appears the -m option of sfdx force:sourc:retrieve could alow for grabbing these same items, but what -m options do I specify? What options are necessary to retrieve new development items (Aura, LWC, etc)?