0

We have a Custom Javascript button on the case object which looks like below

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}

var caseObj     = new sforce.SObject("Case");
caseObj.Id      = '{!Case.Id}';
caseObj.OwnerId = 'xyz000111222';
var result2     = sforce.connection.update([caseObj]);
if (result2[0].success=='true') {
    var caseCmt         = new sforce.SObject("CaseComment");
    caseCmt.ParentId    = '{!Case.Id}';
    caseCmt.CommentBody = 'Passing Customer Service for resolution';
    var result1          = sforce.connection.create([caseCmt]);
    if (result1[0].success=='false') {
        alert(result1[0].errors);}
    else {location.reload(true);}}
else{alert(result2[0].errors);}

I am new to SalesForce and trying to learn how to convert the button in to Ligthning component. I tried running the Lightning Experience Configuration Converter and I got the button partially converted and this is what I see

<aura:component extends="c:LCC_GenericLightningComponent" >
    <aura:set attribute="partially" value="false"></aura:set>
    <aura:set attribute="isAdditionalObject" value="false"></aura:set>

    <!-- User Interface -->

    <div class="slds-scrollable slds-p-around_medium slds-text-heading_small" id="modal-content-id-1">
        <p class="slds-hyphenate" style="height: 6.75rem;"><a style="outline: 0;" href="https://github.com/developerforce/LEXComponentsBundle" target="_blank">Sample Lightning Component Action</a></p>
        <br/>
    </div>
    <div class="slds-modal__footer">
        <lightning:button class="slds-button_brand" onclick="{!c.accept}" label="Accept"/>
    </div>


    <!-- The height of the modal is defined in Salesforce, when you create the new action. -->
    <!-- Recommended height size: 250px -->

</aura:component>

And the controller

({
    accept : function(component, event, helper) {
        $A.get("e.force:closeQuickAction").fire();
    }
})

Can anyone please let me know what is the next step to approach this.

2

Your JavaScript button is too complex to be converted to a Lightning component in an automated way. The Lightning component produced by the conversion tool is essentially a placeholder.

You have two real options here. One is to work with a developer to build a Lightning component replicating this functionality. The other is to reconceive the functionality such that you can achieve it using other, declarative, Salesforce automation tools that don't require code.

For example, while I do not know the details of the business process or requirements behind this button, I could see potentially replacing it with a Quick Action to perform one or more field updates, plus a Process to post a Case Comment upon that modification. See this documentation on creating a Change Owner Quick Action.

Either way, it's not something that's going to be push-button. You'll need to define the business process in detail and evaluate the solution options.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.