Friday, 15 September 2017

Lightning - Change quote status to approve

Lightning - Change Quote Status to Approve

Few days back i got chance to work on lightning. Al thought it is very small request but wanted to share my code here.

Business Requirement

On Quote object( Custom Object due to some business requirements) clients needs a button called "Approve". so once this button is clicked quote status should be changed to approve. Doing this in classic is a piece of cake but lightning is a bit new for me, so i have to put some time to get familiar with Aura framework.

Solution

Created a lightning component and use it on the object specific action to show a button in lightning.

Handler Code

({ doInit : function(component, event, helper) {
    var qid = component.get("v.recordId");
        var action = component.get("c.saveQuote");
        action.setParams({"QID": qid});

        action.setCallback(this, function(response) {
            var state = response.getState();
            if(component.isValid() && state == "SUCCESS"){
                var c = response.getReturnValue();
                component.set("v.quote", c);
                $A.get("e.force:closeQuickAction").fire();
                $A.get('e.force:refreshView').fire();
            }

            else {
                console.log('There was a problem : '+response.getError());
            }
        });
        $A.enqueueAction(action);


} 
})

Class Code

public class ApproveQuoteController 
{
public static FConnect__Service_Quote__c saveQuote(Id QID){
    FConnect__Service_Quote__c Cquote= [select id,name,FConnect__Account__c,FConnect__Status__c,FConnect__Contact__c,FConnect__Site__c,FConnect__Problem__c
                   from FConnect__Service_Quote__c where id=:QID limit 1];
                       
        Cquote.FConnect__Status__c = 'Approved';

        update Cquote;
        return Cquote;
    }
}

Component Code

<aura:component controller="ApproveQuoteController" implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId,force:lightningQuickAction" access="GLOBAL" >
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />

</aura:component>

22 comments:

  1. Are you looking for Best Cloud Computing training in Delhi. DIAC offering best online Salesforce training , CRM training, Salesforce Lightning - Admin developer training. Free Demo Class. Call now 9310096831.

    ReplyDelete
  2. This article is very much helpful and i hope this will be an useful information for the needed one.Keep on updating these kinds of informative things...

    Embedded training in chennai | Embedded training centre in chennai | Embedded system training in chennai | PLC Training institute in chennai | IEEE final year projects in chennai | VLSI training institute in chennai

    ReplyDelete
  3. You’ve written a really great article here. Your writing style makes this material easy to understand.. I agree with some of the many points you have made. Thank you for this is real thought-provoking content
    python training in chennai
    python training in Bangalore

    ReplyDelete
  4. This is such a good post. One of the best posts that I\'ve read in my whole life. I am so happy that you chose this day to give me this. Please, continue to give me such valuable posts. Cheers!
    java online training | java training in pune

    java training in chennai | java training in bangalore

    ReplyDelete
  5. The site was so nice, I found out about a lot of great things. I like the way you make your blog posts. Keep up the good work and may you gain success in the long run.

    angularjs online Training

    angularjs Training in marathahalli

    angularjs interview questions and answers

    angularjs Training in bangalore

    angularjs Training in bangalore

    ReplyDelete
  6. And indeed, I’m just always astounded concerning the remarkable things served by you. Some four facts on this page are undeniably the most effective I’ve had.
    iosh course in chennai

    ReplyDelete
  7. Please let me know if you’re looking for an author for your site. You have some great posts, and I think I would be a good asset.
    iosh course in chennai

    ReplyDelete
  8. Amazing article. Your blog helped me to improve myself in many ways thanks for sharing this kind of wonderful informative blogs in live. I have bookmarked more article from this website. Such a nice blog you are providing ! Kindly Visit Us @ Best Travels in Madurai | Tours and Travels in Madurai

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. This comment has been removed by the author.

    ReplyDelete
  11. I Prepared many of the blogs that are not useful.And then I was read our useful content and information I was fully read and that you give up and step very useful.Hence, I congregate to our faithfulness post.
    java training in chennai

    java training in tambaram

    aws training in chennai

    aws training in tambaram

    python training in chennai

    python training in tambaram

    selenium training in chennai

    selenium training in tambaram

    ReplyDelete
  12. Just found your post by searching on the Google, I am Impressed and Learned Lot of new thing from your post.
    Dell Boomi training in bangalore





    ReplyDelete
  13. Pull- up your socks and knot your tie. Gonna have a good salary package job after completing Big-data Hadoop training in Chennai at Infycle. Infylce is completely for Software training and placement by friendly trainees, good atmosphere, 200% practical classes, and more.

    ReplyDelete