0

I have created an ltng:outApp app and created a lightning component inside it. This is embedded in a visualforce page as a button. So when I click on the button, the component will be created and I will clone a record in the lightning controller.After cloning I want to redirect to the newly cloned record page rather than the VF page which displayed.This part is not working.

var resultData = response.getReturnValue();// this is ID of the cloned record
            var context = component.get("v.UserContext");
            console.log('--resultData--'+resultData+'----'+context);
            if(context != undefined) {
                if(context == 'Theme4t' || context == 'Theme4d') {
                    console.log('VF in S1 or LEX');
                    sforce.one.navigateToSObject(resultData);
                } else {
                    console.log('VF in Classic');                         
                    window.location.assign('/'+resultData);                        
                }
            } else {
                console.log('standalone Lightning Component');
                 window.location.assign('/'+resultData);
            }

I can see the console.log('standalone Lightning Component'); But after that window.location is not working .IF I give window.open it will show me refused to connect error

  • This worked for us- window.location.href = 'your URL'; – Raul Nov 27 '18 at 10:15
  • You can use this : window.top.location.href = '/one/one.app#/sObject/'+sfdcRecordId+'/view' – MIX DML Nov 27 '18 at 10:55
  • This question is more or less a duplicate of How to navigate in lightning out?. Using window navigation methods is not really supported in the Lightning Experience, even if it may work in certain circumstances. – Adrian Larson Nov 28 '18 at 16:32
0

To navigate to the record created or in lightning page you should give the URL or you can try

if(// your condition){
        var quoteId= component.get("v.recId");// get the record ID from the lighting page(implement force:hasRecordId)
        var navEvt = $A.get("e.force:navigateToSObject");
         navEvt.setParams({
         "recordId": quoteId
            });
        navEvt.fire();
| improve this answer | |

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.