You need to sign in to do that
Don't have an account?

saving a record on change of value
Hi,
I the component , i have created a field with the following code:
I have created a save button with the following code:
I want the receipt number to be updated to the record "record.recordid" whenever i click on save button. Can anyone please tell me how to acheieve this? A sample code will be really helpful
I the component , i have created a field with the following code:
<lightning:input aura:id="field" label="Receipt Number" placeholder="Receipt Number" required="true" />The field needs to be saved in a record with record id = record.recordid. I am able to get the record.recordid .
I have created a save button with the following code:
<lightning:button label="Save and Close" aura:Id="saveBtn" iconPosition="left" variant="brand" onclick="" > </lightning:button>
I want the receipt number to be updated to the record "record.recordid" whenever i click on save button. Can anyone please tell me how to acheieve this? A sample code will be really helpful
If you want to create a sObject record from a record then the first thing you need to do is create an attribute of that record in your component, like this():
<aura:attribute name="ReceiptNumber" type="number"/>
<lightning:input aura:id="field" label="Receipt Number" type="number" value="{!v.ReceiptNumber}" />
//Now creating lightning button to save the record
<lightning:button label="Save and Close"
aura:Id="saveBtn"
iconPosition="left"
variant="brand"
onclick="{!c.SaveRecord}"
/>
//SaveeRecord will be function of your JS controller which will be called when button gets clicked.
In this function you will get the value of ReceiptNumber attribute using component.get("v.ReceiptNumber"). Now you can use that value anyhow you want in your logic.
Let me know if it helps.
Thanks!
All Answers
I am having a little trouble understanding you request.
Can you elaborate using an example?
i have created a input field to capture the receipt number from the component. the want to store that value in the record on click of save button.
i want a sample code for it
If you want to create a sObject record from a record then the first thing you need to do is create an attribute of that record in your component, like this():
<aura:attribute name="ReceiptNumber" type="number"/>
<lightning:input aura:id="field" label="Receipt Number" type="number" value="{!v.ReceiptNumber}" />
//Now creating lightning button to save the record
<lightning:button label="Save and Close"
aura:Id="saveBtn"
iconPosition="left"
variant="brand"
onclick="{!c.SaveRecord}"
/>
//SaveeRecord will be function of your JS controller which will be called when button gets clicked.
In this function you will get the value of ReceiptNumber attribute using component.get("v.ReceiptNumber"). Now you can use that value anyhow you want in your logic.
Let me know if it helps.
Thanks!
The record id which whom i want to bind thid value is in app.id . How do i use it in JS controller logic to bind the value to specific record?