0

I would like to create a lightning component for update field based on selected value from "select list" in lwc.

I need this component in "force:lightningQuickAction" - so when user open a example ticket and click the button XYZ component will show (it's alraedy done) and select status - click save then the selected status should be change of current ticket record. What should I do next with it ? What I need to write in controller ?

<aura:component implements="force:lightningQuickAction" >
<lightning:select aura:id = "statusSelect" name="statusChoose" label="Setup new status" required="true" onchange="{! c.onChange }">
    <option value="working">Working</option>
    <option value="escalated">Escalated</option>
    <option value="done">Done</option>
</lightning:select>
<button class="slds-button slds-button--neutral uiButton--default uiButton--brand uiButton" type="button">
<lightning:button variant="brand" label="Save" onclick="{! c.saveClick }" />
</button>

0

You don't need to write these much code to update the status value of record. Create an action of type update a record with status field added on action layout and put the action on page layout in salesfoce mobile and lightning experience action section.

It will allow you the same thing to do you are trying to do with custom component.

This trailhead module shows you how you can create object specific action:- Create an Object-Specific Action

Another way of doing is to use lightning Data service. lightning:recordeditform will allow to do the same with few lines of code and without callig an apex method for dml operation.

In your case, You need to store selected value in an attribute and pass this value along with current record id to an apex method which will update the current record. Refer the example in given reference below to call an apex method

Reference:-

  1. Calling a Server-Side Action
  2. Has Record Id

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.