1

I have a custom button/action of Action Type: lightning component on a custom object that, when clicked, automatically creates a new case record of a certain Record Type, if it isn't linked to an existing case. The requirement is- to avoid automatically creating a case record, and instead give the user an option to manually choose the record type from a pop-up, similar to creating a new case from the Case object itself and then choosing a record type. I'm not too familiar with Lightning dev and would really appreciate any guidance.

Below is the JS controller code:

({
    CreateCase: function (component, event, helper) {

        var caseNumberAdd3 = component.get("c.CasenumberShopp");
        var caseDetails = [];
        var caseid;
        caseNumberAdd3.setParams({
            "shoppingactivityID": component.get("v.recordId")
        });
        caseNumberAdd3.setCallback(this, function (response) {

            if (response.getState() === "SUCCESS") {
                caseDetails = response.getReturnValue();
                document.getElementById('loader1').style.display = 'none';
                if (caseDetails === null) {
                    document.getElementById('mainDiv44').style.display = 'block';

                }
                else {
                    $.each(caseDetails, function (key, value) {

                        if (key === "Id") {
                            caseid = value;
                            var urlEvent = $A.get("e.force:navigateToURL");
                            urlEvent.setParams({
                                "url": '/' + value
                                //component.get("v.caseid")
                            });
                            urlEvent.fire();

                        }
                    });

                }

            }
        });
        $A.enqueueAction(caseNumberAdd3);

    }, close: function (component, event, helper) {
        document.getElementById("successMsg").style.display = 'none';
    }
})
  • Thanks for including your relevant code - it is appreciated if you try to format it cleanly and use the built-in code formatting (indent by 4 spaces) so it can easily be read. – David Reed Mar 19 '18 at 22:59
  • I think, this explain what You are looking for.......sfdcmonkey.com/2017/05/09/… – amidstCloud Mar 20 '18 at 2:01
1

Your code has no solution for this and you pretty much need to restart in order to accomplish this user story.

Instead of giving you the code for this(which I don't have), I'm going to tell you how to make it and you can do the logic.

New action --> direct it to a lightning component.

in the lightning component, create a new modal window that queries for the record types. Then display the record types dynamically, give the users a button to select the record type. do an onchange once selected, close that modal window and make another one depending on which record type they chose, you can either choose to have X amount of customised modal windows, 1 for each record type, using wrapped auraif statements for each one or you can have 1 and have each field dependant on an aurif to whether or not it shows up in the 2nd modal window. Then you simply provide a save button to allow them to save their record.

  • Thanks a lot for the step-by-step instructions, enough pointers to help get started. – ssazi Mar 19 '18 at 23:20
  • if this helped, please mark as answer :) – Tim Willis Mar 19 '18 at 23:31

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.