• kirsan
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 1
    Replies
Hello,
I am assigning a lead to one user by using radio button, for this I am using javascript remote functionality.
I am passing userId to static variable in controller. Whenever I clicked on Assign button the static variable is getting null.
Below is my code, any one can help me to fix this issue.

<apex:page controller="LeadDealerAssignmentProcess">
    <script type="text/javascript">
        function fnbuttoncheck(id)  
            {  
                var radiobutton = document.getElementById(id);
                 if  (radiobutton.checked == true )       
                    {  
                       alert('------->'+id);
                         Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.LeadDealerAssignmentProcess.changeIdvalue}', id,
                                                                        function(result, event){},{escape: true});
                        
                     }  
            }  

    </script>
    <apex:form >
       
     <apex:pageblock >
         
        <apex:pageBlockTable value="{!DealerAssignment}" var="dealer" id="myTable">
             <apex:column ><input type="radio" name="selectRadio" onclick="fnbuttoncheck(this.id)" checked="{!dealer.isSelected }" id="{!dealer.usr.id}" /></apex:column>
            <apex:column value="{!dealer.usr.Name}"/>
            <apex:column value="{!dealer.usr.Title}"/>
            <apex:column value="{!dealer.usr.Dealer_Title__c}"/>
            <apex:column value="{!dealer.usr.Dealer_Outlet_Name__c}"/>
            <apex:column value="{!dealer.usr.CompanyName}"/>
           </apex:pageBlockTable>
           <apex:pageBlockButtons >
           <apex:commandButton value="Assign" action="{!AssignLeadtoDealer}"/>
           <apex:commandButton value="Cancel" action="{!doCancel}" immediate="true"/>
           </apex:pageBlockButtons>
           </apex:pageblock>
        <!--<input type="text" name="userid" value="{!userStr}"/>-->
       
   </apex:form>
</apex:page>

public class LeadDealerAssignmentProcess{
    Public static String userStr;
    
    public list<Wrapperuser> getDealerAssignment(){
       List<Wrapperuser> listwrapperuser= new list<Wrapperuser>();
        Lead__c leadslist = [select id, Name, Assigned_Dealer__c, Assigned_Dealer__r.Dealer_Sales_Manager__c from Lead__c WHERE id = : ApexPages.currentPage().getParameters().get('id') LIMIT 1];
        List<User> UserDealers = [select Id, Name, Title, Dealer_Title__c, Dealer_Outlet_Name__c, CompanyName, Email from User LIMIT 10];//leadslist.Assigned_Dealer__r.Dealer_Sales_Manager__c LIMIT 1];
 
  for(user usr: UserDealers){
  Wrapperuser wuser= new Wrapperuser ();
  wuser.usr=usr;
  wuser.isSelected = true;
  listwrapperuser.add(wuser);
  }
        return listwrapperuser;
        
        
    }
    public pageReference doCancel(){
        return null;        
    }
     
    @RemoteAction
    public static void changeIdvalue(String struserId)
    {
      userStr = struserId;
       System.debug('Id from remote action-->'+struserId);
       System.debug('UserID--->'+userStr );
        //userStr = struserId;
        //Pagereference pageRef = Apexpages.currentPage();
        //pageref.getParameters().put('UserId',struserId);
       // return userStr ;
       
        
    }
    public PageReference AssignLeadtoDealer(){
     
         string leadid= apexpages.currentpage().getparameters().get('id');
         
         Lead__c lead = new Lead__c(id=leadid, ownerid=userStr);
         System.debug('Id >>>>>>>>' + userStr+ ' Lead Id >>>>' + leadid);
         update lead;
         
         System.debug(' User ID >>>>>>>>> ' + userStr);
        return null;        
    }
    
    public class Wrapperuser{
    
    public boolean isSelected {get;set;}
    public user usr {get;set;}
    
    public Wrapperuser()
    {
        isSelected = false;
        usr=new user();
    }
    }
    
}
  • November 25, 2016
  • Like
  • 0
Hello,
I have type and subtype pick list fields, sub type is dependent by type field. new button is override by vf page. In vf page I have component.
I am trying to populate the type and subtype values from javascript in component,
Issue:
I am able to populate the type field but not able to populate the subtype field, In page subtype is disabled, I tried rerender the page/pageblock but not able to populate/enabled the sub type in vf page.
Kindly suggest me how to popualate/enabled the subtype field?
Thanks in advance..
  • April 04, 2016
  • Like
  • 0
Hi All,

I am trying to create a site using "site.com" .Can you any guide me how to build a site using site.com and how to create multiple tabs for that app?

Is there any docs regarding site.com.
  • August 06, 2014
  • Like
  • 0

what is the use of  DML  operations and select statements in triggers??

  • December 12, 2012
  • Like
  • 0

can we perform two different actions like send email & feild update in workflows?

  • December 12, 2012
  • Like
  • 0

how to store data into two different sobjects at a time?

 

  • December 12, 2012
  • Like
  • 0

can we perform two different actions like send email & feild update in workflows?

  • December 12, 2012
  • Like
  • 0