0

I am trying to create a button in visualforce page which should open Visual Flow in New tab and that visualforce page will be added to app builder page. Button Code:

<button title="Submit New Disclosure" class="slds-button slds-button--brand" onclick="gotoLink('/{!JSENCODE(FlowUrl)}',false)" target="_blank">
                              Submit New Disclosure  
                            </button>

Script:

 var params = function() 
        {
            function urldecode(str) 
            {
                return decodeURIComponent((str+'').replace(/\+/g, '%20'));
            }
            function transformToAssocArray( prmstr ) 
            {
                var params = {};
                var prmarr = prmstr.split("&");
                for ( var i = 0; i < prmarr.length; i++) {
                    var tmparr = prmarr[i].split("=");
                    params[tmparr[0]] = urldecode(tmparr[1]);
                }
                return params;
            }
            var prmstr = window.location.search.substr(1);
            return prmstr != null && prmstr != "" ? transformToAssocArray(prmstr) : {};
        }();

    function gotoLink(url,classicView) 
        {

            sforce.connection.sessionId = '{!GETSESSIONID()}';
            if(classicView)
            {
                sforce.one.navigateToURL(url);
            }
            else
            {
                sforce.one.navigateToURL(params['sfdcIFrameOrigin']+'/one/one.app#/sObject'+url+'/home');
            }
        }

Controller:

UrlDomainName  = URL.getSalesforceBaseUrl().getHost();
FlowUrl=UrlDomainName + 'flow/Transaction_Matter_Creation';

any workaround for this.

Thanks

1

I got the solution.

Button:

 <button title="Submit New Form" class="slds-button slds-button--brand" onclick='gotoLinkFlow(false)'>
                              Submit New Form  
                            </button>

Script:

function gotoLinkFlow(flow) 
        {
            var url="{!URLFOR('/flow/Newform')}";
            window.parent.location=url;
        }

if your using this page to different profile then.in profile permissions you need to check a permission Run Flows. but it's coming with classic view.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy