I am having two client-side controller methods, How to pass the response of the first wire method as a parameter to the second wire method. The second wire method is dependent on the first methods returned data.  @wire(method2, { oinputmap: "$inputMap", intname: "$interName" })   wiredresponse({ error, data }) {     //({ oinputmap: this.inputMap,intname: this.interName })     if (data) {       var responseObj = JSON.parse(data);       console.log("result activate card" + responseObj);       if (responseObj.Result.Code === 0) {         this.description = "Card Activated." + responseObj.Result.Description;         //TODO: Update XPAC in card       } else {         this.description = responseObj.Result.Description;       }       console.log("result" + responseObj.Result.Description);     } else if (error) {       console.log("buildandcallinterface:Exception in fetching card number");     }   }
123645
According to the documentation  in order to retrieve a list of picklist values for an object we need to pass in a Record Type Id which can be retrieved using the getObjectInfo method.   The issue is that these are both wire functions and I cannot figure out how to chain these methods.  If I try code like the following:  getObjectInfo({ objectApiName: ACCOUNT_OBJECT })             .then(result =&gt; {                 return getPicklistValues({recordTypeId: result.defaultRecordTypeId, fieldApiName: TYPE_FIELD});             })             .then(result =&gt; {                 this.picklistValues = result.data             })             .catch(error =&gt; {                 this.error = error;             });   I get an error      render threw an error in 'c:getpicklistexample' [Imperative use is not   supported. Use @wire(getObjectInfo).]   If I try something like   @track rtId;      @wire(getObjectInfo, { objectApiName: ACCOUNT_OBJECT })     handleResult({error, data}) {         if(data) {             this.rtId = data.defaultRecordTypeId;         }     }      @wire(getPicklistValues, {recordTypeId: this.rtId,fieldApiName: TYPE_FIELD})     picklistValues;   Then it throws an internal server error. Anybody have an idea as to how I could retrieve the record type Id and then call to get the pick list values like the documentation suggests?  FYI my imports are:  import { LightningElement, wire, track } from 'lwc'; import { getPicklistValues, getObjectInfo } from 'lightning/uiObjectInfoApi'; import TYPE_FIELD from '@salesforce/schema/Account.Type'; import ACCOUNT_OBJECT from '@salesforce/schema/Account';
103822
I have requirement to call a child controller function from parent controller whenever the event occurs in parent side.  for e.g  ABC is parent component and DCE is child component, this child component has Span of Text tag and X symbol. when I click on x it is clearing the value using child controller. ABC parent component has Form element and child component is one one of in form.  My requirement is to clear the this child component value when parent component button is clicked.  here is the below sample code of what am trying because i cannot post actual code here  ParentComponent.cmp     &lt;aura:registerEvent name="clrValues" type="c:ClearValues"/&gt;     &lt;div&gt;          &lt;c:ChildComponent textValue="test"/&gt;          &lt;ui:button label="Save"/&gt;          &lt;ui:button label="Clear" press="{!c.clear}"/&gt;           &lt;/div&gt;  &lt;/aura:component&gt;   ParentController.js  ({     clear : function(component, event, helper) {         var evtFire = component.getEvent("clrValues");          evtFire.fire();     } })   ClearValues.evt  &lt;aura:event type="APPLICATION" description="Event template" /&gt;   ChildComponent.cmp  &lt;aura:component &gt;     &lt;aura:handler name="setValues" event="c:ClearValues" action="{!c.clear}"/&gt;     &lt;aura:attribute name="textValue" type="String" default="test"/&gt;     &lt;div &gt;     &lt;ui:inputText label="Expense Name" value="{!v.textValue}" aura:id="input1"/&gt;     &lt;/div&gt;  &lt;/aura:component&gt;   ChildController.js  ({     clear : function(component, event, helper) {         helper.clearValues(component,event);     } })
25453
I have created a 'control' using jQuery and used jQuery.extend to assist in making it as OO as possible.  During the initialisation of my control I wire up various click events like so  jQuery('#available input',              this.controlDiv).bind('click', this, this.availableCategoryClick);   Notice that I am pasing 'this' as the data argument in the bind method. I do this so that I can get at data attached to the control instance rather from the element that fires the click event.   This works perfectly, however i suspect there is a better way  Having used Prototype in the past, I remember a bind syntax that allowed you to control what the value of 'this' was in the event.  What is the jQuery way?
119645
Component  &lt;aura:component implements="force:lightningQuickAction"&gt;     &lt;ui:inputNumber aura:id="num1"/&gt; +     &lt;ui:inputNumber aura:id="num2"/&gt;     &lt;br/&gt;     &lt;ui:button label="Add" press="{!c.showToast}"/&gt; &lt;/aura:component&gt;   Controller    ({         showToast : function(component, event, helper) {         var n1 = component.find("num1").get("v.value");         var n2 = component.find("num2").get("v.value");          // Display the total in a "toast" status message          var resultsToast = $A.get("e.force:showToast");         resultsToast.setParams({             "title": "Quick Add: " + n1 + " + " + n2,             "message": "The total is: " + (n1 + n2) + "."         });         resultsToast.fire();          // Close the action panel          var dismissActionPanel = $A.get("e.force:closeQuickAction");         dismissActionPanel.fire();         }     })   ERROR MESSAGE     This page has an error. You might just need to refresh it. Action   failed: c$TestCheck1$controller$showToast [Cannot read property   'setParams' of undefined] Failing descriptor:   {c$TestCheck1$controller$showToast}
55180
So I have a method that takes as a parameter an Id of a object and uses it to make an external callout.  Unfortunately I can't seem to figure out any way to test it.  @isTest static void sometimes_salesforces_sucks() {    My_Object__c foo = new My_Object__c(Name='test');    insert foo;    MyClient client = new MyClient();    MyMockResponseGenerator mockResponse = new MyMockResponseGenerator();    Test.setMock(HttpCalloutMock.class,mockResponse);     Test.startTest();    client.bar(foo.Id);    Test.stopTest(); }    says that using start/stop test should work, but it doesn't work for me
18034
when i try to save the following code, i got the error below. Following same instructions given in this link, but still errors. Am i doing anything wrong here? please suggest.    @isTest private class WebSvcCalloutTest {     @isTest static void testEchoString() {         Account a = new Account(name='Tester',SAP_KUNNR__c='1172');         insert a;                       // This causes a fake response to be generated         Test.setMock(WebServiceMock.class, new WebServiceMockImpl());      } }   Error:  Save error: Method does not exist or incorrect signature: Test.setMock(Type, WebServiceMockImpl)    WebSvcCalloutTest.cls         @isTest global class WebServiceMockImpl implements WebServiceMock {    global void doInvoke(            Object stub,            Object request,            Map&lt;String, Object&gt; response,            String endpoint,            String soapAction,            String requestName,            String responseNS,            String responseName,            String responseType) {          sapComDocumentSapSoapFunctionsMcS.Z_GSSMWFM_HNDL_EVNTRQST00 sap1 = new sapComDocumentSapSoapFunctionsMcS.Z_GSSMWFM_HNDL_EVNTRQST00();                Map&lt;String,String&gt; mapSAP = new Map&lt;String,String&gt; {};         sapComDocumentSapSoapFunctionsMcS.ZgssmbstDatarcrd01 req = new sapComDocumentSapSoapFunctionsMcS.ZgssmbstDatarcrd01();               sapComDocumentSapSoapFunctionsMcS.ZGssmwfmHndlEvntrqst00Response_element ret =  sap1.ZGssmwfmHndlEvntrqst00('',req);         response.put('response_x', ret);     } }
15435
I fear this is probably a bit of a dummy question, but it has me pretty stumped.  I'm looking for the simplest way possible to pass a method of an object into a procedure, so that the procedure can call the object's method (e.g. after a timeout, or maybe in a different thread).  So basically I want to:   Capture a reference to an object's method. Pass that reference to a procedure. Using that reference, call the object's method from the procedure.   I figure I could achieve the same effect using interfaces, but I thought there was another way, since this "procedure of object" type declaration exists.  The following doesn't work, but might it help explain where I'm confused...?  interface    TCallbackMethod = procedure of object;    TCallbackObject = class     procedure CallbackMethodImpl;     procedure SetupCallback;   end;  implementation  procedure CallbackTheCallback(const callbackMethod: TCallbackMethod); begin   callbackMethod(); end;  procedure TCallbackObject.CallbackMethodImpl; begin   // Do whatever. end;  procedure TCallbackObject.SetupCallback; begin   // following line doesn't compile - it fails with "E2036 Variable required"   CallbackTheCallback(@self.CallbackMethodImpl); end;   (Once the question is answered I'll remove the above code unless it aids the explanation somehow.)
4013
If I have two variables:  Object obj; String methodName = "getName";   Without knowing the class of obj, how can I call the method identified by methodName on it?  The method being called has no parameters, and a String return value. It's a getter for a Java bean.
118537
In C#, if you want a method to have an indeterminate number of parameters, you can make the final parameter in the method signature a params so that the method parameter looks like an array but allows everyone using the method to pass as many parameters of that type as the caller wants.  I'm fairly sure Java supports similar behaviour, but I cant find out how to do it.
103862
I am using lightning navigation to pass recordId from parent component to child component.  On button click i am navigating to child component like below url -    I need to get the recordId from URL in child component and pass to apex methods.  I tried the below, but not getting the recordId.    import { LightningElement, api, track, wire } from "lwc";     import { getRecord, generateRecordInputForUpdate } from "lightning/uiRecordApi";     import { CurrentPageReference } from "lightning/navigation";      export default class TestLWC extends LightningElement {      @track getrecordId;       @wire(CurrentPageReference)       currentPageReference;      setCurrentPageReference(currentPageReference) {     this.currentPageReference = currentPageReference;   }       getrecordId =         this.currentPageReference &amp;&amp; this.currentPageReference.state.c__recordId      @wire(getData, { getrecordId: "$getrecordId" })      }
118759
Question  I'm writing some code that needs to be able to get the values of the parameters from the method that called into the class. I know how to get all the way to the ParameterInfo[] array, but I don't know how to then get the values. Is this even possible?  If it is, I think it has something to do with using the MethodBody property from the MethodInfo object, which allows you to inspect the IL stream, including properties, but I don't know how to do it, and I haven't found applicable code on Google.  Code  // Finds calling method from class that called into this one public class SomeClass {     public static void FindMethod()     {         for (int i = 1; i &lt; frameCount; i++)         {             var frame = new StackFrame(i);             var methodInfo = frame.GetMethod();             if (methodInfo.DeclaringType != this.GetType())             {                 string methodName = frame.GetMethod().Name;                 var paramInfos = methodInfo.GetParameters();                  // Now what?? How do I get the values from the paramInfos                  break;             }             else if (i == frameCount - 1)             {                 throw new TransportException("Couldn't find method name");             }         }     } }
76431
When I load script/console, sometimes I want to play with the output of a controller or a view helper method.  Are there ways to:   simulate a request? call methods from a controller instance on said request? test helper methods, either via said controller instance or another way?
23491
I created a test Opportunity -       Opportunity Opp = new Opportunity();     Opp.Name = 'Test Opportiunity ';     Opp.AccountId = acct.id;     Opp.Business_Line__c = 'Capital Markets';     Opp.Result_Reason__c = 'Amenities';     Opp.CloseDate = System.today();     Opp.StageName = 'Qualified';     Opp.LeadSource = 'Web';     Opp.Type = 'New Customer - New Business';     Opp.Product_Type_Interests__c = 'ActiveDisclosure';     insert Opp;   and then created the controller and passed onto my class:  ApexPages.StandardController sc = new ApexPages.StandardController(Opp); AssociateECPController   ac = new AssociateECPController(sc);  PageReference myVfPage = Page.AssociateECP; Test.setCurrentPage(myVfPage);  // Put Id into the current page Parameters ApexPages.currentPage().getParameters().put('id',Opp.Id); String id = ApexPages.currentPage().getParameters().get('id'); System.assert('true',id==null);   and Put Id into the current page Parameters:  ApexPages.currentPage().getParameters().put('id',Opp.Id);   However when I run the test class the id is coming as null in the actual class and I'm not able to cover the if part.  Any ideas?
7733
I have a VisualForce page that is made up of different components. One of my components is passed in a Case and displays the case fields.   If there is an edit to the case I would like to save it with associated controller to that component. If saving produces an error I would like to pass that error to the parent VisualForce page/controller and display the error message there.   Is it possible to communicate with other components/VisualForce pages? I am looking for something similar to an event in lightning components.
56399
I have 2 components. VariationComponent and PGP_Tab_bar_item. I create PGP_Tab_bar_item in the markup of VariationComponent . Want to perform some action on PGP_Tab_bar_item if event is fired from PGP_Tab_bar_item component.  I am using component.find({instancesOf:}) but it is giving an empty Array[].  VariationComponent :  &lt;aura:attribute name="projects" type="Project__c[]" /&gt;  &lt;ul class="slds-tabs--default__nav" role="tablist"&gt; &lt;aura:iteration items="{!v.projects}" var="project" indexVar="index"&gt;     &lt;c:PGP_Tab_bar_item project="{!project}" isProgramme="false" variationId="{!v.variationId}" active="false"/&gt; &lt;/aura:iteration&gt; &lt;/ul&gt;  &lt;ui:button label="Save" press="{!c.handlePGPTab}" class="slds-button slds-button--brand" aura:id="handle" /&gt;   Controller:  handlePGPTabEvent : function(component, event, helper){     var tabs = component.find({ instancesOf : "c:PGP_Tab_bar_item" }) ;     console.log(tabs); // output Array[] in console }
3150
What is the best practice for writing apex test classes where you have multiple callouts? My Test Class would then be testing the secondCallout method which happens to also call a firstCallout method that has a callout in itself. My question is, what is the appropriate way to be able to run the mock test for both methods? Main Class public class myclass {    public static String firstCallOut() {         HttpRequest req = new HttpRequest ();         HttpResponse res = new HttpResponse();         req.setMethod('POST');         //code snippets only          return res.getBody().    }     public static void secondCallOut() {        String resultFromFirstCallout = firstCallOut();          HttpRequest req = new HttpRequest ();         req.setMethod('POST');         req.setBody(resultFromFirstCallout);         //code snippets only      }   }  Mock Class public with sharing class MyMockclass implements HttpCalloutMock {          protected Integer code;     protected String status;     protected String body;     protected Map&lt;String, String&gt; responseHeaders;     public MyMockclass (Integer code, String status, String body, Map&lt;String, String&gt; responseHeaders) {       this.code = code;       this.status = status;       this.body = body;       this.responseHeaders = responseHeaders;     }      public HTTPResponse respond(HTTPRequest request) {         // Create a fake response         HttpResponse response = new HttpResponse();         for (String key : this.responseHeaders.keySet()) {           response.setHeader(key, this.responseHeaders.get(key));         }         response.setBody(this.body);         response.setStatusCode(this.code);         response.setStatus(this.status);         return response;       }  }  Test Class @isTest(seeAllData=false) public class myclassTest{     static testMethod void myTestMethod(){               Map&lt;String, String&gt; responseHeader = new Map&lt;String, String&gt;();             responseHeader .put('Content-Type','application/json');              MyMockclass mock= new MyMockclass (                 200,                 'success',                 'Succesful',                 responseHeader              );             Test.setMock(HttpCalloutMock.class, mock);               Test.startTest();             myclass.secondCallOut();             Test.stopTest();         }
46641
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady); var listTitle = []; var listUrl = []; var listIsActive = []; var listOrder = [];  function sharePointReady(){ var siteUrl = mysite;     var clientContext = new SP.ClientContext(siteUrl); var oList = clientContext.get_web().get_lists().getByTitle('Privacy Statements');  var camlQuery = new SP.CamlQuery(); camlQuery.set_viewXml(''); this.collListItem = oList.getItems(camlQuery);  clientContext.load(collListItem);  clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));         }    function onQuerySucceeded(sender, args) {  var listItemEnumerator = collListItem.getEnumerator();   while (listItemEnumerator.moveNext()) {     var oListItem = listItemEnumerator.get_current();     listTitle.push(oListItem.get_item('Title'));     listUrl.push(oListItem.get_item('PrivacyStatementUrls').get_url());      listIsActive.push(oListItem.get_item('IsActive'));     listOrder.push(oListItem.get_item('SortOrder'));    } sessionStorage.setItem('Title', JSON.stringify(listTitle)); sessionStorage.setItem('Url', JSON.stringify(listUrl)); sessionStorage.setItem('IsActive', JSON.stringify(listIsActive)); sessionStorage.setItem('Order', JSON.stringify(listOrder)); var retrievedTitle = sessionStorage.getItem("Title"); var arTitle = JSON.parse(retrievedTitle); var retrievedUrl = sessionStorage.getItem("Url"); var arUrl = JSON.parse(retrievedUrl); var retrievedIsActive = sessionStorage.getItem("IsActive"); var arIsAct = JSON.parse(retrievedIsActive); var retrievedOrd = sessionStorage.getItem("Order"); var arOrd = JSON.parse(retrievedOrd);  var test = '' for(x=0; x&lt;arTitle.length+1;x++) {      for(i=0; i&lt;arTitle.length+1;i++)     {          if(arIsAct[i] == true){             if(arOrd[i] == x){                 test +='&lt;a href="'+arUrl[i]+'"&gt;'+arTitle[i]+'&lt;/a&gt;&lt;br&gt;';             }            }      } }  document.getElementById('test').innerHTML = test; }  function onQueryFailed(sender, args) {  alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); }   I am trying to use caching with sessionstorage when getting items from a list, so it doesn't have to keep querying the list over and over again. It can just check with the sessionstorage and if its in the list there is no need to get the item but if its not in sessionstorage get the item from the list. I am not sure how to do this, my code above shows my attempt