can any one help in changing the onclick javascript button to lightning component?..becasuse javascript button are not supported in lightning.  {!REQUIRESCRIPT("/soap/ajax/37.0/connection.js")}  var Suite = '{!Contract__C.Suite__c}'; var check = '{!Contract__C.Notification_check__c}'; var amount= '{!Contract__C.amount__c}'; var blackReview = '{!Contract__C.black_Review__c}';  var blackReview= blackReview!= '' &amp;&amp; blackReview!= 'No'; var Suite = Suite != ''; var amount= Number(amount.replace(/[^0-9\.]+/g,"")); amount = amount&gt;=1000.00; //alert(blackReview+" "+ amount+" " +Suite );  if ((amount|| blackReview|| Suite)&amp;&amp; check == 0){ var con= new sforce.SObject("Contract__C"); con.id = "{!Contract__C.Id}"; con.Notification_check__c = 1; result = sforce.connection.update([con]); }
74788
We depend on a javascript button to allow our salesforce screens to interact with another web application. We read some elements from the salesforce contact, and then call a js func hosted on another web site to pass that contact info to the other web site. The js func has a call back, so when the other web site is finished, our js in salesforce can save some data to the salesforce contact.  But.... as lightning lacks javascript buttons, we have been locked out of lightning.  I just found this:    But it is not clear: Can I do a javascript button now in lightning, or do I still need to wait for more pieces from salesforce?  We would love to have a path forward with lightning.
60693
I'm using stackoverflow.com with JavaScript off. I accept this comes with somewhat less functionality, however for the most part SO works fine.  If I look at the home page (), every single button on there except for two types works with JS off.  The first second is that the "x Votes; y answers;z views" mouse-over indicates they're links but clicking them does nothing. This one is less of an issue because the user can still click the question title, and they're only implied buttons anyway.  The second (and bigger) issue is the "Add" buttons next to "Favorite Tags" and "Ignored Tags". These are explicit buttons that don't do anything with JS off. There is no working JS substitute for them (the "tag subscriptions" link itself works, but the page it goes to doesn't work with JS off, but that's another bug report).
9288
How can I change the colors of lightning-button?  I tried doing this in my css:  .my-button {     background-color: #14a6bc;     color: #ffffff; }   and applying that class to my &lt;lightning-button&gt; and removing the variant but I still get the base colors? I am trying to use these examples:
89933
Hi, I want to create a table in my lightning component. I created 2 lightning:input fields and want to change the vertical alignment to "middle" but it does not work.   I tried to do the following:  &lt;td  class="slds-align-middle"&gt;&lt;lightning:input /&gt;&lt;/td&gt;   and this:   &lt;td&gt;&lt;span class="slds-align-middle"&gt;&lt;lightning:input /&gt;&lt;/span&gt;&lt;/td&gt;   and this:  &lt;td Style="text-align: center;vertical-align:top;" valign="middle"&gt;&lt;lightning:input /&gt;&lt;/td&gt;   I am using slds:      &lt;table class="slds-table slds-table_bordered slds-table_cell-buffer slds-table_col-bordered"&gt;      &lt;thead&gt;...&lt;/thead&gt;      &lt;tbody&gt;       &lt;tr&gt; [td in the middle of the cell] &lt;/tr&gt;      &lt;/tbody&gt;     &lt;/table&gt;   I hope someone can help me. Thanks!
13185
I have created lightning quick action to add my component for some functionality.   so from my quick action. When I do some validation like       var opp = component.get("v.objOpportunity");     if(!opp.Name.length || !opp.CloseDate.length )     {         var toastEvent = $A.get("e.force:showToast");         toastEvent.setParams({             "message": 'Opportunity name and close date can not be empty.',             "type": "Error"         });         toastEvent.fire();         return;     }   So the toast message display behind the modal. Please check below screenshot.   Any solution for this issue? I don't want to write custom error message functionality to display to user.
30301
I've tried this:  string newScript = textBox1.Text; HtmlElement head = browserCtrl.Document.GetElementsByTagName("head")[0]; HtmlElement scriptEl = browserCtrl.Document.CreateElement("script"); lblStatus.Text = scriptEl.GetType().ToString(); scriptEl.SetAttribute("type", "text/javascript"); head.AppendChild(scriptEl); scriptEl.InnerHtml = "function sayHello() { alert('hello') }";   scriptEl.InnerHtml and scriptEl.InnerText both give errors:  System.NotSupportedException: Property is not supported on this type of HtmlElement.    at System.Windows.Forms.HtmlElement.set_InnerHtml(String value)    at SForceApp.Form1.button1_Click(Object sender, EventArgs e) in d:\jsight\installs\SForceApp\SForceApp\Form1.cs:line 31    at System.Windows.Forms.Control.OnClick(EventArgs e)    at System.Windows.Forms.Button.OnClick(EventArgs e)    at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)    at System.Windows.Forms.Control.WmMouseUp(Message&amp; m, MouseButtons button, Int32 clicks)    at System.Windows.Forms.Control.WndProc(Message&amp; m)    at System.Windows.Forms.ButtonBase.WndProc(Message&amp; m)    at System.Windows.Forms.Button.WndProc(Message&amp; m)    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m)    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)   Is there an easy way to inject a script into the dom?
56430
I'm not able to get refreshApex() working in an lwc. . Here are the key elements of the js file:  import { LightningElement, track, api, wire } from 'lwc'; import getBlasts from '@salesforce/apex/Blast.getBlasts'; import { refreshApex } from '@salesforce/apex';  export default class BlastWaveTree extends LightningElement {     @api recordId;     @track blastData;     @track error;     @wire(getBlasts, { CampaignId: '$recordId' })         wireBlastData({             error,             data         }) {             if (data) {                 let tempjson = JSON.parse(JSON.stringify(data).split('waves').join('_children'));                 this.blastData = tempjson;          } else {                 this.error = error;         }     }      @api     refresh() {         return refreshApex(this.blastData);      }   My code varies from the doc examples for 2 reasons:    The example code doesn't separate out the Apex response into error and data, the pattern I've been following as shown elsewhere. This data is going into a lightning-tree-grid so I have to process it a bit before assigning it to blastData.   I've tried return refreshApex(this.wireBlastData) as well, and that doesn't work.  Ultimately, I want to call the refresh function from the parent component (hence, the @api), but I've simplified it (till I get it working) by calling the refresh function from a button on this same component. I added a console.log line in the refresh() function so I know the button is calling the function. It just doesn't refresh. I'm also watching the apex logs as I push the refresh button, and there's no apex activity.  Here's the template:  &lt;template&gt; &lt;lightning-card title="Blasts" icon-name="custom:custom3"&gt;     &lt;div slot="actions"&gt;         &lt;lightning-button-group &gt;             &lt;lightning-button-icon icon-name="utility:refresh"  alternative-text="Refresh" onclick={refresh}&gt;&lt;/lightning-button-icon&gt;             &lt;lightning-button label={buttonLabel} onclick={toggleWaves}&gt;&lt;/lightning-button&gt;              &lt;lightning-button label="New Blast" onclick={onNewBlast} variant="Brand"&gt; &lt;/lightning-button&gt;         &lt;/lightning-button-group&gt;     &lt;/div&gt;     &lt;div class="slds-m-around_medium"&gt;         &lt;lightning-tree-grid              data={blastData}              columns={columns}              key-field="id"              hide-checkbox-column="true"              onrowaction={handleRowAction} &gt;         &lt;/lightning-tree-grid&gt;     &lt;/div&gt; &lt;/lightning-card&gt;     What am I missing?  Here's the error detail from the browser dev tools:      lds.js:2 Uncaught (in promise) Error: Refresh failed because resolved configuration is not available.     at Object.e.refresh [as refreshApex] (lds.js:2)     at l.refresh (blastWaveTree.js:4)     at callHook (aura_prod.js:24)     at sa (aura_prod.js:2)     at aura_prod.js:2     at _ (aura_prod.js:2)     at HTMLElement.e (aura_prod.js:2)     at l (aura_prod.js:2)     at Un.call.a (aura_prod.js:2)     at Array.forEach (&lt;anonymous&gt;) e.refresh   @   lds.js:2 refresh @   blastWaveTree.js:4 callHook    @   aura_prod.js:24 sa  @   aura_prod.js:2 (anonymous) @   aura_prod.js:2 _   @   aura_prod.js:2 e   @   aura_prod.js:2 l   @   aura_prod.js:2 Un.call.a   @   aura_prod.js:2 t   @   aura_prod.js:2 Lt  @   aura_prod.js:2 t.$$lwcEventWrapper$$   @   aura_prod.js:2
83312
Is there a way to view &amp; modify the code of standard lightning components that are visible when editing the Napili template in the community builder. I was wondering if I could modify some of the code and use it as lightning out.
89928
I am using Salesforce Lightning Design system and I'm currently working on a local html file and would like to create a button that when clicked, will cause a modal to open. I'd like to have a similar output like bootstrap modal that is triggered when a modal button is clicked. Is it possible to create a similar behavior without controllers? We will integrate it to salesforce later on.
18604
I've been trying out React for a couple of days and I tried to build a button component with some conditionals. Everything works but I feel like I am not doing it the right way. Could anyone review my code and give me some advice and tell me what I am doing wrong or what i could do better. I think I am using too many return statements. I use Typescript for type checking. Would appreciate any help! import { Link } from &quot;gatsby&quot;;  interface Props {   content: string,   color: string,   path?: string,   type?: string }  export default function Button(props: Props): JSX.Element {   let elementType;    const checkProps = () =&gt; {     const availableColors = ['blue', 'grey', 'dark-grey', 'white'];     const borderColors = [''];     let buttonStyle;      // Check if props.color exists in availableColors     if(!availableColors.includes(props.color)) {       console.error(`&quot;${props.color} color key not available for button style`);       return;     }          buttonStyle = buttonStyles[`button--${props.color}`];      // Check if props.content is valid     if(!props.content) {       console.error(`&quot;${props.content} is not valid as content`);       return;     }      // Check if props.type exists     if(!props.type) {       elementType = &lt;button className={ buttonStyle }&gt;{ props.content }&lt;/button&gt;       return;     }      if(props.type !== 'link') {       console.error(`&quot;${props.type} is not a valid type, use 'link' instead or use nothing for default button`);       return;     } else {         elementType = &lt;Link to={ props.path } className={ buttonStyle }&gt;{ props.content }&lt;/Link&gt;     }   }    checkProps();    return (     &lt;React.Fragment&gt;       { elementType }     &lt;/React.Fragment&gt;   ); }```
105818
Is it possible to add a new button to an existing panel or an existing node that runs a custom operator?  How can I do this?
12365
I am making an component in lightning. i want to know how can we use the state and county picklist in this particular code.  secoundly the functionality of save and cancel button is also not working in the lightning component.Help me out.  Thanx          &lt;div class="container"&gt;                     &lt;form class="formbusiness"&gt;         &lt;h1&gt;Account Information&lt;/h1&gt;         &lt;div class="row"&gt;             &lt;h1 class="headingB"&gt;Business Account Info&lt;/h1&gt;             &lt;div class="col-md-6"&gt;                 &lt;ui:inputText aura:id="b_cname" class="form-control" value="{!v.newBAccount.Name}" placeholder="Company Name" required="true"/&gt;                 &lt;ui:inputNumber aura:id="b_bphone" class="form-control" value="{!v.newBAccount.Phone}" placeholder="Phone" required="true"/&gt;                 &lt;ui:inputEmail aura:id="b_bemail" class="form-control" value="{!v.newBAccount.Email__c}" placeholder="Email"/&gt;             &lt;/div&gt;             &lt;div class="col-md-6"&gt;                 &lt;ui:inputText aura:id="b_bstreet" class="form-control" value="{!v.newBAccount.BillingStreet}" placeholder="Billing Street"/&gt;                 &lt;ui:inputText aura:id="b_bcity" class="form-control" value="{!v.newBAccount.BillingCity}" placeholder="Billing City"/&gt;                 &lt;ui:inputText aura:id="b_state" class="form-control" value="{!v.newBAccount.BillingStateCode}" placeholder="State"/&gt;                 &lt;ui:inputText aura:id="b_country" class="form-control" value="{!v.newBAccount.BillingCountryCode}" placeholder="Country"/&gt;                 &lt;ui:inputNumber aura:id="b_zipcode" class="form-control" value="{!v.newBAccount.BillingPostalCode}" placeholder="Zip Code"/&gt;             &lt;/div&gt;         &lt;/div&gt;         &lt;div class="row"&gt;             &lt;h1 class="headingB"&gt;Respective Contact&lt;/h1&gt;             &lt;div class="col-md-6"&gt;                 &lt;ui:inputText aura:id="b_rcfirstname" class="form-control" value="{!v.newBRCAccount.FirstName}" placeholder="First Name"/&gt;                 &lt;ui:inputText aura:id="b_rclastname" class="form-control" value="{!v.newBRCAccount.LastName}" placeholder="Last Name" required="true"/&gt;                 &lt;ui:inputNumber aura:id="b_rcmobile" class="form-control" value="{!v.newBRCAccount.MobilePhone}" placeholder="Mobile" required="ture"/&gt;             &lt;/div&gt;             &lt;div class="col-md-6"&gt;                 &lt;ui:inputEmail aura:id="b_rcemail" class="form-control" value="{!v.newBRCAccount.Email}" placeholder="Email"/&gt;                 &lt;ui:inputNumber aura:id="b_rcphone" class="form-control" value="{!v.newBRCAccount.Phone}" placeholder="Phone"/&gt;                                 &lt;/div&gt;         &lt;/div&gt;         &lt;div class="buttonB"&gt;             &lt;ui:button label="Save" press="{!c.createBAccount}"/&gt;             &lt;ui:button label="Cancel"/&gt;         &lt;/div&gt;             &lt;/form&gt;         &lt;/div&gt;
1582
I have a &lt;lightning:recordViewForm in a custom lightning component.  When I hardcode the recordId attribute it works, but when I pass an attribute in it fails without any error messages in either the console or the debug log.  Component  &lt;aura:handler name="init" value="{!this}" action="{!c.doInit}" /&gt; &lt;aura:attribute name="recordId" type="Id"&gt;&lt;/aura:attribute&gt;  &lt;lightning:recordViewForm recordId="{! v.recordId }" objectApiName="MyCustomObject__c"&gt;      &lt;lightning:outputField fieldName="Name" /&gt;  &lt;/lightning:recordViewForm&gt;   JavaScript Controller  doInit : function(cmp, event, helper) {      // var recordId = helper.getQueryStringParameter('recordId');      cmp.set("v.recordId", "a0C4E000003YMkmUAG"); }   The above does not work, even if I put the recordId directly into the attribute.  It only works when I set the Id in the recordId attribute of the &lt;lightning:recordViewForm like below:  &lt;lightning:recordViewForm recordId="a0C4E000003YMkmUAG" objectApiName="MyCustomObject__c"&gt;      &lt;lightning:outputField fieldName="Name" /&gt;  &lt;/lightning:recordViewForm&gt;
122028
I have a requirement where I use  in Lightning and I have implemented the same as below code. I created a Lightning Tab from this component and used in Lightning Experience. Component: &lt;aura:component implements=&quot;force:appHostable&quot;&gt;     &lt;ltng:require scripts=&quot;/resource/treeTable/treeTableJS.js&quot; afterScriptsLoaded=&quot;{!c.loadScripts}&quot;/&gt;     &lt;aura:attribute name=&quot;temp&quot; type=&quot;String&quot; default=&quot;none&quot; /&gt;     &lt;aura:attribute name=&quot;content&quot; type=&quot;String[]&quot; default=&quot;item1,item2,item3,item4&quot; /&gt;     &lt;table id=&quot;table&quot;&gt;         &lt;tbody&gt;             &lt;tr data-tt-id=&quot;parent&quot;&gt;                 &lt;td&gt;&lt;ui:button label=&quot;Click&quot; press=&quot;{!c.selectClick}&quot; /&gt;&lt;/td&gt;                 &lt;td&gt;Content&lt;/td&gt;             &lt;/tr&gt;             &lt;aura:iteration items=&quot;{!v.content}&quot; var=&quot;item&quot; indexVar=&quot;index&quot;&gt;                 &lt;tr data-tt-id=&quot;{!'child'+index}&quot; data-tt-parent-id=&quot;parent&quot;&gt;                     &lt;td&gt;&lt;/td&gt;                     &lt;td&gt;{!item}&lt;/td&gt;                 &lt;/tr&gt;             &lt;/aura:iteration&gt;         &lt;/tbody&gt;     &lt;/table&gt; &lt;/aura:component&gt;  Controller: ({     loadScripts : function(component, event, helper) {         $(&quot;#table&quot;).treetable({                 expandable: true             }, {                 force: true             }, {                 initialState: &quot;collapsed&quot;             });     },      selectClick : function(component, event, helper) {         if(component.get(&quot;v.temp&quot;)===&quot;none&quot;){             component.set(&quot;v.temp&quot;,&quot;plus&quot;);             $(&quot;#table&quot;).treetable(&quot;expandNode&quot;, &quot;parent&quot;);         } else{             component.set(&quot;v.temp&quot;,&quot;none&quot;);             $(&quot;#table&quot;).treetable(&quot;collapseNode&quot;, &quot;parent&quot;);          }     }, })  Now about the issue, when I use this in Lightning tab first time it works (meaning straight forward scenario), but now from this page I navigate to any standard record page (be it Accounts record page) or even Home page and come back to this lightning tab, it does not work. We have to refresh the page to make it work again. Any resolve so that we don't need to refresh the page? Please help. Note: Lightning Locker service is disabled.
99580
I am new to Salesforce development. I made a trigger that creates a new asset record and autofills some of the fields on said record. What I want ultimately would be a button that I can put on the "Products" related list on the opportunity page that does what my trigger does. From what I understand, I can't just call my trigger on the button click, and I have to create a VF page or an Apex class that uses the trigger's logic. Does anyone know how I would go about doing this? Here's my code:  trigger ConvertOpportunitiesToAssets on Opportunity (after update) {      List&lt;Asset&gt; a = new List&lt;Asset&gt;();     OpportunityLineItem oli = new OpportunityLineItem();      for(Opportunity o: Trigger.new)     {                   a.add( new Asset(             PSI_Supplier__c = o.Supplier__c,             PSI_Opportunity__c = oli.Product2Id,             AccountId = o.Accountid,             Name = oli.Product2Id,             Product2Id = oli.Product2Id,             Product_Name__c = oli.Product_Name__c             ));            }     insert a; }   Thanks in advance!  UPDATE So I tried making the trigger into a class and button (thanks sfdcfox!), but now it won't work. Here's what I've got:      global class OpportunityWS{     webservice static void createAsset(Id opportunityId)     {         List&lt;Asset&gt; a = new List&lt;Asset&gt;();         Opportunity o = new Opportunity();         OpportunityLineItem oli = new OpportunityLineItem();          a.add( new Asset(             PSI_Supplier__c = o.Supplier__c,             PSI_Opportunity__c = oli.Product2Id,             AccountId = o.Accountid,             Name = oli.Product2Id,             Product2Id = oli.Product2Id,             Product_Name__c = oli.Product_Name__c             ));                 insert a;      } }  {!RequireScript("/soap/ajax/34.0/connection.js")} {!RequireScript("/soap/ajax/34.0/apex.js")} function success() { var alertString="Success!";  alert(alertString);  } function error() { var alertString="Error!";  alert(alertString);  } sforce.connection.sessionId = "{!$Api.Session_ID}"; sforce.apex.execute("OpportunityWS", "createAsset", { opportunityId: "{!Opportunity.Id}" }, { onSuccess: success, onFailure: error });   I can't tell if it's something wrong with the class or the button. I think it must be the class.  UPDATE(AGAIN) Alright so I followed Doug's advice and tried to use the opportunityId to query the opportunity and opportunityLineItem sobjects, was able to compile without errors. But now I'm getting the error message that I made in the button thrown and the asset isn't being created. Unfortunately, I haven't been able to track down the issue. Here's the OpportunityWS apex class that I've updated since last edit:  global class OpportunityWS{ webservice static void createAsset(Id opportunityId) {     List&lt;Asset&gt; a = new List&lt;Asset&gt;();     List&lt;Opportunity&gt; o = [SELECT Supplier__c, Accountid FROM Opportunity WHERE Id = :opportunityId];     List&lt;OpportunityLineItem&gt; oli = [SELECT Product2Id, Product_Name__c FROM OpportunityLineItem WHERE Id = :opportunityId];      a.add( new Asset(         PSI_Supplier__c = o[0].Supplier__c,         PSI_Opportunity__c = oli[0].Product2Id,         AccountId = o[1].Accountid,         Name = oli[0].Product2Id,         Product2Id = oli[0].Product2Id,         Product_Name__c = oli[1].Product_Name__c         ));             insert a; }   }
107908
I have began developing a button to automatically close the current case but I can't seem to get it working. I have tried a few different approaches but would someone be able to point me in the right direction.  As it stands the button does nothing, I feel like im on the right track, looking for someone who has done something similar with regards to updating fields from within a lightning component.   CMP  &lt;aura:component controller="AmexComm_SecureMsgController" implements="forceCommunity:availableForAllPageTypes,force:hasRecordId" access="global"&gt; &lt;aura:attribute name="record" type="Case"/&gt; &lt;aura:attribute name="caseStatus" type="String"/&gt; &lt;aura:attribute name="caseId" type="String" default="{!v.recordId}"/&gt;  &lt;aura:handler name="init" value="{!this}" action="{!c.doInit}"/&gt;   &lt;button class="slds-button slds-button--neutral newsbutton" style="float:right"  onclick="{!c.closeCase}"&gt;Close Case&lt;/button&gt;   AmexComm_SecureMsgController   @AuraEnabled     public static Case getCase(Id caseId){         return([Select id, Atrium_Subject__c, Atrium_AmexSubject__c, Status, Atrium_Message_Status__c, Contact.Name, ContactId, CreatedDate, Message_Number__c, LastModifiedDate, Description__c,                 (SELECT id, Name From Attachments)                                 From Case Where id=:caseId]);     }     @AuraEnabled     public static Case closeCase(Case caseA){        update caseA;        return caseA;     }   Controller  { doInit : function(component, event, helper) {     component.set("v.isError", false)     component.set("v.showEditView", false);     component.set("v.errorMsg", "");      var action = component.get("c.getCase");     action.setParams({         caseId : component.get("v.caseId")     });      action.setCallback(this, function(a) {         if (a.getState() === "SUCCESS") {             component.set("v.record", a.getReturnValue());             helper.getStatusPickListValue(component);         }     });      $A.enqueueAction(action); },  closeCase : function (component, event, helper) {     var action = component.get("c.closeCase");     var Status = component.get("v.record.Status") //get value of field     //console.log("Status: " Status);     action.setParams({Status : Closed});      $A.enqueueAction(action); },   Helper  getStatusPickListValue : function(component) {          var action = component.get("c.getCaseStausPickList");         action.setCallback(this, function(response) {             var state = response.getState();             var hasImg = false;             if (component.isValid() &amp;&amp; state === "SUCCESS") {                  var statusPickList = response.getReturnValue();                 component.set("v.lstCaseStatus", statusPickList);                  console.log('status picklist ::', component.get("v.lstCaseStatus"));             }         });         $A.enqueueAction(action);      },
121649
I am unable to pass parameter from the lightning controller to the apex class. Whenever I use debug the passed value seems null.  JavaScript Controller  add : function(cmp,event,helper) {      event.target.parentNode.style.display = 'none';     document.getElementById("cartdiv").style.display = 'block';     var selectedAccount =event.target.id;      var act = cmp.get("c.Cartveg");     act.setParams({"s":selectedAccount});     act.setParams({"cartlist" : cmp.get("v.cart")});     act.setCallback(this,function(a){         cmp.set("v.cartitem",a.getReturnValue());     });            $A.enqueueAction(act);     cmp.set("v.whichButton", selectedAccount); }   Apex Class  @AuraEnabled public static List&lt;Vegetable__c&gt; Cartveg(string s,List&lt;Vegetable__c&gt; cartlist) {       system.debug(s);   List&lt;Vegetable__c&gt;  clist= [SELECT Id, Name , Price__c , img__c                                  FROM Vegetable__c where Name =:s];      clist.addAll(cartlist);      system.debug(clist);     return clist; }   Value of s is null. Please help