{"id":2075,"date":"2016-08-30T09:49:24","date_gmt":"2016-08-30T09:49:24","guid":{"rendered":"http:\/\/www.greytrix.com\/blogs\/salesforce\/?p=2075"},"modified":"2025-06-10T09:37:02","modified_gmt":"2025-06-10T09:37:02","slug":"save-records-via-lightning-app","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/salesforce\/2016\/08\/30\/save-records-via-lightning-app\/","title":{"rendered":"Save Records in Salesforce via Lightning App"},"content":{"rendered":"<p style=\"text-align: justify;\">Salesforce Lightning Component framework is a UI framework for developing dynamic apps for mobile and desktop devices. It\u2019s a modern framework for building single-page applications engineered for growth. Salesforce Lightning makes it easier to build responsive applications for any device. In the earlier blog \u2018<a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2016\/08\/20\/retrieve-records-in-lightning\/\">Retrieve Records via Lightning\u2019<\/a>, we discussed how to read records from Salesforce and display them via Lightning. Now taking a step ahead, get insights on how to save a record in Salesforce database using Lightning.<\/p>\n<p style=\"text-align: justify;\">Open the developer console. The developer console as we already know is preferred to create Lightning components, controller and apps to preview the functionality. We created a Lightning component named \u2018Lightning_SaveRec\u2019 in our developer console which will be used in the Lightning App. First, we write a function in our apex class that would implement the functionality of saving the records, ensure that your method is annotated with \u2018@AuraEnabled\u2019. Here\u2019s the snippet for the Apex class handling the functionality of inserting\/saving records in Salesforce.<\/p>\n<div id=\"attachment_2077\" style=\"width: 687px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2016\/08\/Img-1-Apex-Class-for-Saving-records-Account.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img fetchpriority=\"high\" decoding=\"async\" aria-describedby=\"caption-attachment-2077\" class=\" wp-image-2077\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2016\/08\/Img-1-Apex-Class-for-Saving-records-Account.png\" alt=\"Apex Class for Saving records-Account\" width=\"677\" height=\"246\" \/><\/a><p id=\"caption-attachment-2077\" class=\"wp-caption-text\">Apex Class for Saving records-Account<\/p><\/div>\n<p style=\"text-align: justify;\">Now, we need to create a Lightning component which will be using this controller. In your developer console create a new Lightning component. Refer the image below regarding the code snippet for your Lightning component &#8211;<\/p>\n<div id=\"attachment_2078\" style=\"width: 545px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2016\/08\/Img-2-Lightning-Component-Account.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" aria-describedby=\"caption-attachment-2078\" class=\" wp-image-2078\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2016\/08\/Img-2-Lightning-Component-Account-1024x627.png\" alt=\"Lightning Component-Account\" width=\"535\" height=\"327\" \/><\/a><p id=\"caption-attachment-2078\" class=\"wp-caption-text\">Lightning Component-Account<\/p><\/div>\n<p style=\"text-align: justify;\">Now we will write the Lightning controller (JavaScript) that will be used in component and its helper class as well. Please refer the below images for controller and helper class respectively. This would mostly be the functions or actions that will be handled on button click and other such actions at the client side.<\/p>\n<div id=\"attachment_2079\" style=\"width: 576px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2016\/08\/Img-3-Lightning-Component-controller-Account.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" aria-describedby=\"caption-attachment-2079\" class=\" wp-image-2079\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2016\/08\/Img-3-Lightning-Component-controller-Account.png\" alt=\"Lightning Component controller-Account\" width=\"566\" height=\"249\" \/><\/a><p id=\"caption-attachment-2079\" class=\"wp-caption-text\">Lightning Component controller-Account<\/p><\/div>\n<p>Lightning Helper class-<\/p>\n<div id=\"attachment_2080\" style=\"width: 554px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2016\/08\/Img-4-Lightning-Helper-class-Account.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2080\" class=\" wp-image-2080\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2016\/08\/Img-4-Lightning-Helper-class-Account.png\" alt=\"Lightning Helper class-Account\" width=\"544\" height=\"465\" \/><\/a><p id=\"caption-attachment-2080\" class=\"wp-caption-text\">Lightning Helper class-Account<\/p><\/div>\n<p style=\"text-align: justify;\">The CSS used in our Lightning component can be downloaded from this link, <a href=\"https:\/\/www.lightningdesignsystem.com\" target=\"_blank\" rel=\"noopener\">download SLDS090<\/a>. Applying the CSS is optional. After downloading the mentioned zip file just upload it in static resources of Salesforce. After implying all the above mentioned steps, just refer the Lightning component in your Lightning app. Once done, just click on \u201cPreview\u201d and then you can view your Lightning App. Once the page is displayed, you can enter the records you want and click on \u201cSubmit\u201d button. This will create a new record in your Salesforce SObject.<\/p>\n<div id=\"attachment_2081\" style=\"width: 267px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2016\/08\/Img-5-Lightning-App-To-Save-records.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2081\" class=\" wp-image-2081\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2016\/08\/Img-5-Lightning-App-To-Save-records.png\" alt=\"Lightning App To Save records\" width=\"257\" height=\"123\" \/><\/a><p id=\"caption-attachment-2081\" class=\"wp-caption-text\">Lightning App To Save records<\/p><\/div>\n<div id=\"attachment_2082\" style=\"width: 595px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2016\/08\/Img-6-Page-side-UI-Account.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2082\" class=\" wp-image-2082\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2016\/08\/Img-6-Page-side-UI-Account-1024x199.png\" alt=\"Page side UI-Account\" width=\"585\" height=\"114\" \/><\/a><p id=\"caption-attachment-2082\" class=\"wp-caption-text\">Page side UI-Account<\/p><\/div>\n<p><span style=\"font-size: Medium;\"><strong>About Us<\/strong><\/span><br \/>\n<a href=\"https:\/\/www.greytrix.com\/\">Greytrix<\/a>\u00a0as a Salesforce Product development partner offers a wide variety of integration products and services to the end users as well as to the Partners across the globe. We offers Consultation, Configuration, Training and support services in out-of-the-box functionality as well as customizations to incorporate custom business rules and functionalities that requires apex code incorporation into the Salesforce platform.<\/p>\n<p><a href=\"https:\/\/www.greytrix.com\/\">Greytrix<\/a>\u00a0has some unique solutions for Cloud CRM such as Salesforce integration with\u00a0<a href=\"https:\/\/www.greytrix.com\/product\/sage-x3\/gumu-x3-salesforce-integration\">Sage Enterprise Management (Sage X3<\/a>),\u00a0Sage Intacct, <a href=\"https:\/\/www.greytrix.com\/product\/sage-100-erp\/gumu-100-salesforce-integration\">Sage 100\u00a0<\/a>and\u00a0<a href=\"https:\/\/www.greytrix.com\/product\/sage-300-erp\/gumu-300-salesforce-integration\">Sage 300 (Sage Accpac)<\/a>. We also offer best-in-class Cloud CRM\u00a0<a href=\"https:\/\/www.greytrix.com\/product\/crm-development\/salesforce-com\">Salesforce customization and development services<\/a> along with services such as Salesforce <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/data-migration-services\">Data Migration<\/a>, <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/integrated-application-development\">Integrated App development<\/a>, <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/custom-development\">Custom App development<\/a> and <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/maintenance-support\">Technical Support<\/a> to business partners and end users.<\/p>\n<p>Greytrix GUMU&#x2122; integration for Sage ERP \u2013 Salesforce is a 5-star app listed on <a href=\"https:\/\/appexchange.salesforce.com\/listingDetail?listingId=a0N30000000psM5EAI\" target=\"_blank\" rel=\"noopener\">Salesforce AppExchange<\/a>.<\/p>\n<p>For more information, please contact us at\u00a0<a href=\"mailto:salesforce@greytrix.com\">salesforce@greytrix.com<\/a>. We will be glad to assist you.<\/p>\n<p><span style=\"font-size: Medium;\"><strong>Related Posts<\/strong><\/span><\/p>\n<ul>\n<li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2016\/08\/20\/retrieve-records-in-lightning\/\" target=\"_blank\" rel=\"noopener noreferrer\">Retrieve Records in Lightning<\/a><\/li>\n<li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2016\/07\/05\/connecting-salesforce-using-soap-api-in-c\/\" target=\"_blank\" rel=\"noopener noreferrer\">Connecting Salesforce using SOAP API in C#<\/a><\/li>\n<li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2016\/07\/04\/syncing-data-using-gumu-sage-erp-x3-integration-for-salesforce\/\" target=\"_blank\" rel=\"noopener noreferrer\">Syncing data using GUMU&#x2122; SAGE ERP X3 Integration for Salesforce<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Salesforce Lightning Component framework is a UI framework for developing dynamic apps for mobile and desktop devices. It\u2019s a modern framework for building single-page applications engineered for growth. Salesforce Lightning makes it easier to build responsive applications for any device. In the earlier blog \u2018Retrieve Records via Lightning\u2019, we discussed how to read records from\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2016\/08\/30\/save-records-via-lightning-app\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[194,206,207,208,210,211,367,907,415,436],"class_list":["post-2075","post","type-post","status-publish","format-standard","hentry","category-gumu-salesforce","tag-javascript","tag-lightning","tag-lightning-basics","tag-lightning-component","tag-lightning-experience-on-salesforce","tag-lightning-insertionofrecords","tag-salesforce","tag-salesforce-developer-console","tag-salesforce-saverecords","tag-saverecords"],"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/2075","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/comments?post=2075"}],"version-history":[{"count":5,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/2075\/revisions"}],"predecessor-version":[{"id":10882,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/2075\/revisions\/10882"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/media?parent=2075"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/categories?post=2075"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/tags?post=2075"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}