• Pritika
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies
My jquery function :

<script type="text/javascript">
            $j = jQuery.noConflict();
           
           
             $j(document).ready(function(){
            $j('.slds-button').click(function(e) {
                e.preventDefault();
                var dialog = $j('<p>Do you want to proceed ahead for creating Sales Area Data for the company?</p>').dialog({
                    buttons: {
                        "Yes": function() {CallApexMethod2();},
                                                                       
                        "No":  function() {alert('No');},
                        "Cancel":  function() {
                            //alert('you chose cancel');
                            dialog.dialog('close');
                        }
                    }
                });
            });
        });
               
            </script>

my earlier javscript function:

 <script>  
            function myJavascriptFunc(){
                if(confirm('Do you want to proceed ahead for creating Sales Area Data for the company?'))
                {
                    CallApexMethod2() ;
                    return false;
                }
                else {CallApexMethod1() ;
                      return false;
                     }
               
            }       
            </script>

action method on page:

<apex:actionFunction name="CallApexMethod1" action="{!save}" rerender="form"/>  
                    <apex:actionFunction name="CallApexMethod2" action="{!RedirectSalesAreaCompany}"  rerender="form"/>

button for invoking jquery:
<apex:commandButton value="Save" id="saveAction"  styleClass="slds-button slds-button--neutral"/>

I also tried javascript remoting, but coudn't understand how to use it in this context.Please help!!
 
Hi,
I am a newbie to Lightning,I have created a custome vf page for Record type selection,based on Record type,It navigates to a vf page or to a standard page.This logic is working fine in classic, but in lightning,the redirection to next vf page is working but redirection to standard page is throwing error and not navigating:

Following is my code snippet:
<apex:page standardController="Account" extensions="LH_CreateNewCompany_Extsn" action="{!redirectCompany}" showHeader="false" standardStylesheets="false" sidebar="false" applyHtmlTag="false" applyBodyTag="false" docType="html-5.0">
 <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"></html>    
</apex:page>

Following is method on redirection:

public class LH_CreateNewCompany_Extsn
{
    
    public Account acc{get;set;}
    ApexPages.standardController m_sc = null;
    public string type{get;set;}
    public string rectypeid;
    public String Record_type { get; set; }
    
    public LH_CreateNewCompany_Extsn(ApexPages.standardController sc)
    {
        m_sc = sc;
        acc = new account();
        acc = (Account)m_sc.getRecord();
        acc.OwnerId = UserInfo.getUserId();       
        rectypeid = ApexPages.currentPage().getParameters().get('rectypeid');
        acc.RecordTypeId =  rectypeid; 
        type = apexpages.currentpage().getParameters().get('rectypeid');
        
    }
  
    public PageReference redirectCompany()
    {
        Id selectedRecordType = ApexPages.currentPage().getParameters().get('RecordType');
        Id recTypeId_Tender = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Tender').getRecordTypeId();
        Id recTypeId_Customer = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Customer').getRecordTypeId();
             
Pagereference newpage = new Pagereference ('/001/e');
newpage.getParameters().put('nooverride','1');
return newpage;
        
        if(recTypeId_Customer == selectedRecordType ){
            
            string str;
            str=userinfo.getUiThemeDisplayed();
            if(str == 'Theme4d')
            {PageReference ReturnPage = new PageReference('/apex/LH_CreateNewCompany_Lightning?rectypeid='+selectedRecordType+'&type=new');
             ReturnPage.setRedirect(true);
            return ReturnPage;}
            else{
                PageReference ReturnPage = new PageReference('/apex/LH_CreateNewCompany?rectypeid='+selectedRecordType+'&type=new');
            ReturnPage.setRedirect(true);
            return ReturnPage;}
                        
            
        }else{ 
           
            PageReference ret=new PageReference('/001/e');   //Not working on lightning
            ret.getParameters().put('nooverride','1');
            return ret;
        }
        return null;
    }
  

     
}
My requirement is if record type A is selected then VF page of account A should be selected ,if record type b is selected then standard account page should be displayed.I don't want the vf page to be displayed at all for other record types.I tried using the action function on the same Page,then it was going in infinite loop.I used action function on a dummy page redirecting to the main page,I wanted to check recordtype selected and on the basis of that it should redirect to vf page or standard page.However somehow it is not able to select the record type and always goes in the Else part,irrespective of what record type I select.

hereis the code snippet:

My Dummy VF Page:
<apex:page standardController="Account" extensions="CreateNewCompany_Extsn" action="{!redirectCompany}" >
</apex:page>

My main VF Page:
<apex:page standardController="Account" extensions="CreateNewCompany_Extsn" id="Page" tabstyle="Account" > 
    <!---- Script ----->
      <script>   
      some logic               
      </script>
   
    <!---- /Script ----->        
    <apex:form id="form">
        <apex:actionFunction ..>          
        <apex:pageBlock title="Company Edit">
            <apex:pageBlockSection title="abc" >
                ....                             
            </apex:pageBlockSection>
            
            <apex:pageBlockButtons >                               
                <apex:commandButton action="{!cancel}" value="Cancel"/> 
                <apex:commandButton value="Save" id="saveAction" onclick="return myJavascriptFunc();"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form> 
</apex:page>

Controller Extension:

public class CreateNewCompany_Extsn
 {

    public Account acc{get;set;}
    ApexPages.standardController m_sc = null;
    public string type{get;set;}
    
    public CreateNewCompany_Extsn(ApexPages.standardController sc)
    {
        m_sc = sc;
        acc = new account();
        acc.OwnerId = UserInfo.getUserId();
        type = apexpages.currentpage().getParameters().get('RecordType');
    }
      public PageReference RedirectSalesAreaCompany()
    {
        Account acc = (Account)m_sc.getRecord();        
        insert acc;
        Pagereference redirectTo=new Pagereference('/apex/CreateSalesAreaData?AccId='+acc.Id+'&type=new'); 
        return redirectTo;
    }
     
     public PageReference redirectCompany()
     {
            String selectedRecordType = ApexPages.currentPage().getParameters().get('RecordType');

            Id recTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Tender').getRecordTypeId();

            if(String.valueOf(recTypeId) == selectedRecordType){               
                PageReference ReturnPage = new PageReference('/apex/CreateNewCompany');           
               ReturnPage.setRedirect(true);
                return ReturnPage;
            }else{            
            return null;
            }
     }
 }


So in this example,even if I select Tender Record type,it still returns null.So I guess it is not able to fetch the record type.
Please Help!!




 
My jquery function :

<script type="text/javascript">
            $j = jQuery.noConflict();
           
           
             $j(document).ready(function(){
            $j('.slds-button').click(function(e) {
                e.preventDefault();
                var dialog = $j('<p>Do you want to proceed ahead for creating Sales Area Data for the company?</p>').dialog({
                    buttons: {
                        "Yes": function() {CallApexMethod2();},
                                                                       
                        "No":  function() {alert('No');},
                        "Cancel":  function() {
                            //alert('you chose cancel');
                            dialog.dialog('close');
                        }
                    }
                });
            });
        });
               
            </script>

my earlier javscript function:

 <script>  
            function myJavascriptFunc(){
                if(confirm('Do you want to proceed ahead for creating Sales Area Data for the company?'))
                {
                    CallApexMethod2() ;
                    return false;
                }
                else {CallApexMethod1() ;
                      return false;
                     }
               
            }       
            </script>

action method on page:

<apex:actionFunction name="CallApexMethod1" action="{!save}" rerender="form"/>  
                    <apex:actionFunction name="CallApexMethod2" action="{!RedirectSalesAreaCompany}"  rerender="form"/>

button for invoking jquery:
<apex:commandButton value="Save" id="saveAction"  styleClass="slds-button slds-button--neutral"/>

I also tried javascript remoting, but coudn't understand how to use it in this context.Please help!!
 
My requirement is if record type A is selected then VF page of account A should be selected ,if record type b is selected then standard account page should be displayed.I don't want the vf page to be displayed at all for other record types.I tried using the action function on the same Page,then it was going in infinite loop.I used action function on a dummy page redirecting to the main page,I wanted to check recordtype selected and on the basis of that it should redirect to vf page or standard page.However somehow it is not able to select the record type and always goes in the Else part,irrespective of what record type I select.

hereis the code snippet:

My Dummy VF Page:
<apex:page standardController="Account" extensions="CreateNewCompany_Extsn" action="{!redirectCompany}" >
</apex:page>

My main VF Page:
<apex:page standardController="Account" extensions="CreateNewCompany_Extsn" id="Page" tabstyle="Account" > 
    <!---- Script ----->
      <script>   
      some logic               
      </script>
   
    <!---- /Script ----->        
    <apex:form id="form">
        <apex:actionFunction ..>          
        <apex:pageBlock title="Company Edit">
            <apex:pageBlockSection title="abc" >
                ....                             
            </apex:pageBlockSection>
            
            <apex:pageBlockButtons >                               
                <apex:commandButton action="{!cancel}" value="Cancel"/> 
                <apex:commandButton value="Save" id="saveAction" onclick="return myJavascriptFunc();"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form> 
</apex:page>

Controller Extension:

public class CreateNewCompany_Extsn
 {

    public Account acc{get;set;}
    ApexPages.standardController m_sc = null;
    public string type{get;set;}
    
    public CreateNewCompany_Extsn(ApexPages.standardController sc)
    {
        m_sc = sc;
        acc = new account();
        acc.OwnerId = UserInfo.getUserId();
        type = apexpages.currentpage().getParameters().get('RecordType');
    }
      public PageReference RedirectSalesAreaCompany()
    {
        Account acc = (Account)m_sc.getRecord();        
        insert acc;
        Pagereference redirectTo=new Pagereference('/apex/CreateSalesAreaData?AccId='+acc.Id+'&type=new'); 
        return redirectTo;
    }
     
     public PageReference redirectCompany()
     {
            String selectedRecordType = ApexPages.currentPage().getParameters().get('RecordType');

            Id recTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Tender').getRecordTypeId();

            if(String.valueOf(recTypeId) == selectedRecordType){               
                PageReference ReturnPage = new PageReference('/apex/CreateNewCompany');           
               ReturnPage.setRedirect(true);
                return ReturnPage;
            }else{            
            return null;
            }
     }
 }


So in this example,even if I select Tender Record type,it still returns null.So I guess it is not able to fetch the record type.
Please Help!!




 

On the standard object "Opportunity" I have the standard object "Product" as a related list. This means that a user can press the button "Add" Product on the Opportunity page. When pressing the Add button the user will then get to choose from products which are of the same currency as defined on the opportunity (I run a multi-currency setup). I would like to be able to customize this view so that for example only products with product name that contains the word "Europe" would appear for the user. The reason is because the list of products are too extensive for the end-user to manage. The goal is to have a field on the opportunity where the user fills in a location, such as Europe, and this would then be used to obtain the proper view for this user when selecting a product.

 

The "Add" button on the product uses Salesforce standard trigger, so this has to be done through visual force. On the product object it is possible to create customized Price Book views of the kind I explain above, but this view cannot be linked to the Add product selection on the opportunity.

 

My question is how I would go about to create this kind of view in visual force?

 

Many thanks,

Paddy