• hareeshn
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 3
    Replies
jquery is not workin for  <apex:inputText  help me on this 

<apex:page >

  <script src="https://code.jquery.com/jquery-1.8.2.js"></script>
    <script src="/soap/ajax/26.0/connection.js" type="text/javascript"></script>
    <script src="https://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
    <link rel="stylesheet" href="https://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css"/>
    <apex:form >
    <script>
    $(document).ready(function() {
    $("#txtboxToFilter").keydown(function(event) {
        // Allow only backspace and delete
        if ( event.keyCode == 46 || event.keyCode == 8 ) {
            // let it happen, don't do anything
        }
        else {
            // Ensure that it is a number and stop the keypress
            if (event.keyCode < 48 || event.keyCode > 57 ) {
           
            alert('please enter numaric');
                event.preventDefault();
            }  
        }
    });
});
  
    </script>
   
    <body>
    <p>click i will diss apire</p>
   
    <apex:inputText id="txtboxToFilter"/>
   <input type="text" id="txtboxToFilter" />
    <button>Click me</button>
    </body>
   </apex:form>
</apex:page>
Hi Bello is my code
----------------------------------------------
vf page
----------------------------------------------

<apex:page standardController="Job__c"  extensions="Unsharerecordcon" >
  <apex:form >
      <apex:pageBlock >
                <apex:selectList size="1"  value="{!jobstunshare}" multiselect="false">
                    <apex:actionSupport event="onchange" reRender="opt2" />
                    <apex:selectOptions value="{!Record}"></apex:selectOptions>
                </apex:selectList>
               
                <apex:selectList size="1" value="{!selectedVa2}" multiselect="false">
                  <apex:actionsupport event="onchange" reRender="opt2,opt3"/>
                  <apex:selectoptions value="{!User}" ></apex:selectoptions>
                </apex:selectList>
               
               
                  <apex:commandLink action="{!manualShareRead}" value="UnShare" id="opt2" onclick="alert('helo')">
                </apex:commandLink> 
             
            
                          
        </apex:pageBlock>
       
  </apex:form>
</apex:page>
--------------------------------------------------------------------------------------------------------------------
apex page
------------------------------------------------------------------------------------------------------------------
public  class Unsharerecordcon

{

         List<user> con2= new List<user>(); 
         public List<job__C> joblist { get;set;}
         public String selectedVa2{get;set;}
         Job__Share jobShr {set;get;}
         public string jobstunshare { get;set;}
         public List<job__share> jobshareset {get;set;}
         public Set<SelectOption> setobj { get;set;}
          public Set<SelectOption> setobjuser { get;set;}
         public List<job__C> joblistun { get;set;}
        
          public Unsharerecordcon()
          {

          }
         
          public Unsharerecordcon(ApexPages.StandardController controller)
          {

          }

          public set<SelectOption> getUser()
          {
         
              List<SelectOption> optionuser = new List<SelectOption>();
             
              for(job__share jshareuser:[select id,userorgroupid  from job__share])
              {
              for(user unuser:[select id,name from user where id =:jshareuser.userorgroupid])
              {
             
              setobjuser =new Set<SelectOption>();
                optionuser.add(new SelectOption(unuser.id,unuser.name));
                setobjuser.addAll(optionuser);
              }
              }
              return setobjuser;
             
         
         
          }
         
           public Set<SelectOption> getRecord()
        
             {
                      List<SelectOption> option = new List<SelectOption>();
                     
                      for(job__share jshare:[ select id,parentid,userorgroupid From  job__share])
                      {
                         
                          for(job__c unjb: [Select id,name From  job__c  where id =:jshare.parentid])
                         {
                                    setobj =new Set<SelectOption>();
                                   option.add(new SelectOption(unjb.id,unjb.name));
                                   setobj.addAll(option);
                         system.debug('option value is '+setobj);
                        
                         }
                     }
                    
                    return setobj;     
          }
        
        
          public PageReference  manualShareRead()
   
            {
                 system.debug('manualunShare');
                joblistun = [select id from job__C where id=:jobstunshare];
                system.debug('jobstunshare value'+jobstunshare);
                con2 = [select id from user where name=:selectedVa2];
                system.debug('selectedVa2 value'+selectedVa2);
                jobShr  = new Job__Share(); 
                jobShr.ParentId = joblistun[0].id;
                jobShr.UserOrGroupId = con2[0].id;
               
               
                delete jobShr;
              
            // Database.SaveResult sr = Database.delete(jobShr,false);
                PageReference nextpage = new PageReference('/apex/CustomTeam');
                 nextpage.setRedirect(true);
                
               
            return nextpage ;
      
         }

  
}
-------------------------------------------
am going in rightway to achive unshare a record using apex and vf ?

Thanks
Hi    for example role hierarchy  CEO----> projectmanager ---->projectlead 

if am sharing a record with projectmanager only CEO and Projectmanger able to see that record not projectlead How to achive this functionality using apex and visual force any ideas  will be appreciated thanks 
am able share a record to user using apex how to unshare a record using apex

here is my code:

vf page
------------------------------------------------------
<apex:page standardController="Job__c"   extensions="Jobformation1usercon">
    <apex:form >
                <apex:selectList size="1" value="{!jobst }" multiselect="false">
                    <apex:selectOptions value="{!Job}"> </apex:selectOptions> 
                     <apex:actionSupport event="onchange" reRender="table,opt1" />
                </apex:selectList>
    
                <apex:selectList size="1" value="{!selectedVal}" multiselect="false">
                <apex:actionSupport event="onchange" reRender="table,opt1" />
                    <apex:selectOptions value="{!Value}">
                    </apex:selectOptions>
                </apex:selectList>
               
                <apex:outputText id="opt12" value="{!selectedVal}"></apex:outputText>
               
               <apex:commandLink action="{!manualShareRead}" value="Share" id="opt1">
                </apex:commandLink>
           
     </apex:form>
</apex:page>

----------------------------------------------------------------------
apex page
----------------------------------------------------------------------------------------
public class Jobformation1usercon
{
 
    
         List<user> con1= new List<user>(); 
         public job__c j {get;set;}
         Public List<string> usertselect{get;set;}
         public string jobst { get;set;}
         public string val{ get;set;}
         public user gp {get;set;}
         public boolean nojb{get;set;}
         public String selectedVal{get;set;}
         public List<job__C> joblist = new List<job__C>();
         public Jobformation1usercon(ApexPages.StandardController controller)
        {
        }
  
    public List<SelectOption> getJob()
     {  
         List<SelectOption> option = new List<SelectOption>();
             
        for(job__c j: [Select id,name From  job__c])
         {
         
             option.add(new SelectOption(j.name,j.name));
             system.debug('option value is '+option);
            
         }
         return option;     
    }
     public List<SelectOption> getValue()
     {  
         List<SelectOption> option = new List<SelectOption>();
             
        for(user gp: [Select id,name From  user  ])
         {
         
             option.add(new SelectOption(gp.name,gp.name));
             system.debug('option value is '+option);
            
         }
         return option;     
    }
                
       public PageReference manualShareRead()
           {
             
               joblist = [select id from job__C where name=:jobst];
               con1 = [select id from user where name=:selectedVal];
               system.debug('PGList value is'+con1);
               system.debug('PGList value is'+joblist);
               Job__Share jobShr  = new Job__Share(); 
               jobShr.ParentId = joblist[0].id;
               jobShr.UserOrGroupId = con1[0].id;
               jobShr.AccessLevel = 'Read';
               jobShr.RowCause = Schema.Job__Share.RowCause.Manual;
              
             Database.SaveResult sr = Database.insert(jobShr,false);
              system.debug('sr value is'+sr);
      
             if(sr.isSuccess())
            {
               system.debug('sr.isSuccess() value:'+sr.isSuccess());
                  system.debug('if sr.isSuccess() block');
               PageReference nextpage = new PageReference('/apex/CustomTeam?id='+joblist[0].id);
             
                return nextpage;
               }
           else {
                  system.debug('inner else sr.isSuccess() block');
                     Database.Error err = sr.getErrors()[0];
                     if(err.getStatusCode() == StatusCode.FIELD_FILTER_VALIDATION_EXCEPTION  && 
                     err.getMessage().contains('AccessLevel')){
                      system.debug(' iner if sr.isSuccess() block');
                      PageReference nextpage = new PageReference('/apex/CustomTeam?id='+joblist[0].id);
                return nextpage;
            }
             else
             {
                      system.debug('outer else sr.isSuccess() block');
               PageReference nextpage = new PageReference('/apex/CustomTeam?id='+joblist[0].id);
                    return nextpage;
               }
             }
         
         }
  
  
       
     }


-------------------------------
here job__c is object name is one text field  am shring a reord to one user here  user is one object  .

if  i want to un share want i need to do please help on this

thanks
hareesh
Hi am tryong to share one job object record to one user using apex  
Job__c is object in that name is one text field   User is one object
 am passing record id to command link but its not working please help on this:

i tryed using pageblock table and datatable but user id un able to pass to controler or takeing first values from select list takeing as default values

vf page
----------------------------------------------------------------------------

<apex:page standardController="Job__c"   extensions="Jobformation1usercon">
    <apex:form >
                <apex:selectList size="1" value="{!jobst }" multiselect="false">
                    <apex:actionSupport event="onchange" reRender="table,opt" />
                    <apex:selectOptions value="{!Job}"> </apex:selectOptions>
                </apex:selectList>
    
                 <apex:outputText id="opt" value="{!jobst }"></apex:outputText>
      
                <apex:selectList size="1" value="{!selectedVal}" multiselect="false">
                <apex:actionSupport event="onchange" reRender="table,opt1" />
                    <apex:selectOptions value="{!Value}">
                    </apex:selectOptions>
                </apex:selectList>
                <apex:outputText id="opt1" value="{!selectedVal}"></apex:outputText>
                    <apex:commandLink action="{!manualShareRead}" value="Share" id="table">
                    <apex:param name="id" value="{!Job__c.id}"/>                 
                </apex:commandLink>
           
     </apex:form>
</apex:page>
-------------------------------------------------------------------------------------------
apex page
---------------------------------------------------
public class Jobformation1usercon
{
 
    
         List<user> con1= new List<user>(); 
         public job__c j {get;set;}
         Public List<string> usertselect{get;set;}
         public string jobst { get;set;}
         public user gp {get;set;}
         public boolean nojb{get;set;}
         public String selectedVal{get;set;}
         public List<job__C> joblist {get;set;}
         public Jobformation1usercon(ApexPages.StandardController controller)
       
       {
           Id id = System.currentPageReference().getParameters().get('id');
     
        }
    public List<SelectOption> getJob()
     {  
         List<SelectOption> option = new List<SelectOption>();
             
        for(job__c j: [Select id,name From  job__c])
         {
         
             option.add(new SelectOption(j.name,j.name));
             system.debug('option value is '+option);
            
         }
         return option;     
    }
     public List<SelectOption> getValue()
     {  
         List<SelectOption> option = new List<SelectOption>();
             
        for(user gp: [Select id,name From  user  ])
         {
         
             option.add(new SelectOption(gp.name,gp.name));
             system.debug('option value is '+option);
            
         }
         return option;     
    }
                
       public PageReference manualShareRead()
           {
             
               Id id = System.currentPageReference().getParameters().get('id');
               system.debug('Id Value is'+id);
               system.debug('aaaaaaaaaaaaaaaaaaaaaa'+selectedVal);
               con1 = [select id from user where name=:selectedVal];
               system.debug('PGList value is'+con1);
               Job__Share jobShr  = new Job__Share(); 
               jobShr.ParentId = id;
               jobShr.UserOrGroupId = con1[0].id;
               jobShr.AccessLevel = 'Read';
               jobShr.RowCause = Schema.Job__Share.RowCause.Manual;
              
             Database.SaveResult sr = Database.insert(jobShr,false);
              system.debug('sr value is'+sr);
      
             if(sr.isSuccess())
            {
               system.debug('sr.isSuccess() value:'+sr.isSuccess());
                  system.debug('if sr.isSuccess() block');
               PageReference nextpage = new PageReference('/apex/CustomTeam?id='+id);
             
                return nextpage;
               }
           else {
                  system.debug('inner else sr.isSuccess() block');
                     Database.Error err = sr.getErrors()[0];
                     if(err.getStatusCode() == StatusCode.FIELD_FILTER_VALIDATION_EXCEPTION  && 
                     err.getMessage().contains('AccessLevel')){
                      system.debug(' iner if sr.isSuccess() block');
                      PageReference nextpage = new PageReference('/apex/CustomTeam?id='+id);
                return nextpage;
            }
             else
             {
                      system.debug('outer else sr.isSuccess() block');
               PageReference nextpage = new PageReference('/apex/CustomTeam?id='+id);
                    return nextpage;
               }
             }
         
         }
  
  
       
     }
how to integrate salesforce with dotnet  any ideas
am unable to get selected item from selectlist and passing to controler  bellow is my code please help me on this

vf page
--------------------------------------------------------------
<apex:page standardController="user"   extensions="Jobformation1usercon">
       <apex:form >
       <apex:pageBlock >
         <apex:pageBlockSection >
           <apex:pageBlockTable value="{!accwraplist }" var="accwrapref">
       
      
       <apex:column headerValue="Job Name" value="{!accwrapref.acc.name}" />      
        <apex:column headerValue="User" >
           <apex:selectList size="1"  rendered="true"  value="{!a}">
             <apex:selectOptions value="{!Value}" >
                               
               </apex:selectOptions>
                 </apex:selectList>
         </apex:column>
          <apex:column headerValue="Share a Record" >
                          <apex:commandLink action="{!manualShareRead}" value="Share">
                     <apex:param name="id" value="{!accwrapref.acc.id}"/>
          </apex:commandLink>
                   </apex:column>
            </apex:pageBlockTable>
         </apex:pageBlockSection>
       </apex:pageBlock>
      </apex:form>
</apex:page>
----------------------------------------------------------------------------
apex controler
--------------------------------------------------------------
public class Jobformation1usercon
{

         List<user> PGList= new List<user>(); 
         public List<job__c> jl {get;set;}
         public user gp {get;set;}
         public boolean nojb{get;set;}
         public String a  {get;set;}
         public List<job__C> acclist {get;set;}
         public List<Accountwraper> accwraplist {get;set;}
         public List<group> lstgroup {get;set;}
  


        public Jobformation1usercon(ApexPages.StandardController controller)
       
       {
    
        accwraplist =new List<Accountwraper>();
        acclist=[select id,name from job__c];
        Accountwraper  objwrap;
        for(job__c objacc:acclist)
        {
        objwrap=new Accountwraper();
        objwrap.acc=objacc;
        system.debug('acclist value'+acclist);
        accwraplist.add(objwrap);
        system.debug(' objwrap value '+objwrap);
        }
       
        //
    }
     public List<SelectOption> getValue()
     {  
         List<SelectOption> option = new List<SelectOption>();
            
        for(user gp: [Select Name From  user  ])
         {
         
             option.add(new SelectOption(gp.id,gp.Name));
             system.debug('option value is '+option);
            
         }
         return option;     
    }
                
       public PageReference manualShareRead()
           {
             
               Id id = System.currentPageReference().getParameters().get('id');
               system.debug('Id Value is'+id);
               system.debug('aaaaaaaaaaaaaaaaaaaaaa'+a);
               PGList = [select id from user where name=:a];
               system.debug('PGList value is'+PGList);
               Job__Share jobShr  = new Job__Share(); 
               jobShr.ParentId = id;
               jobShr.UserOrGroupId = PGList[0].id;
               jobShr.AccessLevel = 'Read';
               jobShr.RowCause = Schema.Job__Share.RowCause.Manual;
              
             Database.SaveResult sr = Database.insert(jobShr,false);
              system.debug('sr value is'+sr);
      
             if(sr.isSuccess())
            {
               system.debug('sr.isSuccess() value:'+sr.isSuccess());
                  system.debug('if sr.isSuccess() block');
               PageReference nextpage = new PageReference('/apex/CustomTeam?id='+id);
             
                return nextpage;
               }
           else {
                  system.debug('inner else sr.isSuccess() block');
                     Database.Error err = sr.getErrors()[0];
                     if(err.getStatusCode() == StatusCode.FIELD_FILTER_VALIDATION_EXCEPTION  && 
                     err.getMessage().contains('AccessLevel')){
                      system.debug(' iner if sr.isSuccess() block');
                      PageReference nextpage = new PageReference('/apex/CustomTeam?id='+id);
                return nextpage;
            }
             else
             {
                      system.debug('outer else sr.isSuccess() block');
               PageReference nextpage = new PageReference('/apex/CustomTeam?id='+id);
                    return nextpage;
               }
             }
         
         }
  
  
        class Accountwraper
        {
        public job__c acc { get;set;}
        public boolean selected { get;set;}
       
        }
     }
Hi Bello is my code
----------------------------------------------
vf page
----------------------------------------------

<apex:page standardController="Job__c"  extensions="Unsharerecordcon" >
  <apex:form >
      <apex:pageBlock >
                <apex:selectList size="1"  value="{!jobstunshare}" multiselect="false">
                    <apex:actionSupport event="onchange" reRender="opt2" />
                    <apex:selectOptions value="{!Record}"></apex:selectOptions>
                </apex:selectList>
               
                <apex:selectList size="1" value="{!selectedVa2}" multiselect="false">
                  <apex:actionsupport event="onchange" reRender="opt2,opt3"/>
                  <apex:selectoptions value="{!User}" ></apex:selectoptions>
                </apex:selectList>
               
               
                  <apex:commandLink action="{!manualShareRead}" value="UnShare" id="opt2" onclick="alert('helo')">
                </apex:commandLink> 
             
            
                          
        </apex:pageBlock>
       
  </apex:form>
</apex:page>
--------------------------------------------------------------------------------------------------------------------
apex page
------------------------------------------------------------------------------------------------------------------
public  class Unsharerecordcon

{

         List<user> con2= new List<user>(); 
         public List<job__C> joblist { get;set;}
         public String selectedVa2{get;set;}
         Job__Share jobShr {set;get;}
         public string jobstunshare { get;set;}
         public List<job__share> jobshareset {get;set;}
         public Set<SelectOption> setobj { get;set;}
          public Set<SelectOption> setobjuser { get;set;}
         public List<job__C> joblistun { get;set;}
        
          public Unsharerecordcon()
          {

          }
         
          public Unsharerecordcon(ApexPages.StandardController controller)
          {

          }

          public set<SelectOption> getUser()
          {
         
              List<SelectOption> optionuser = new List<SelectOption>();
             
              for(job__share jshareuser:[select id,userorgroupid  from job__share])
              {
              for(user unuser:[select id,name from user where id =:jshareuser.userorgroupid])
              {
             
              setobjuser =new Set<SelectOption>();
                optionuser.add(new SelectOption(unuser.id,unuser.name));
                setobjuser.addAll(optionuser);
              }
              }
              return setobjuser;
             
         
         
          }
         
           public Set<SelectOption> getRecord()
        
             {
                      List<SelectOption> option = new List<SelectOption>();
                     
                      for(job__share jshare:[ select id,parentid,userorgroupid From  job__share])
                      {
                         
                          for(job__c unjb: [Select id,name From  job__c  where id =:jshare.parentid])
                         {
                                    setobj =new Set<SelectOption>();
                                   option.add(new SelectOption(unjb.id,unjb.name));
                                   setobj.addAll(option);
                         system.debug('option value is '+setobj);
                        
                         }
                     }
                    
                    return setobj;     
          }
        
        
          public PageReference  manualShareRead()
   
            {
                 system.debug('manualunShare');
                joblistun = [select id from job__C where id=:jobstunshare];
                system.debug('jobstunshare value'+jobstunshare);
                con2 = [select id from user where name=:selectedVa2];
                system.debug('selectedVa2 value'+selectedVa2);
                jobShr  = new Job__Share(); 
                jobShr.ParentId = joblistun[0].id;
                jobShr.UserOrGroupId = con2[0].id;
               
               
                delete jobShr;
              
            // Database.SaveResult sr = Database.delete(jobShr,false);
                PageReference nextpage = new PageReference('/apex/CustomTeam');
                 nextpage.setRedirect(true);
                
               
            return nextpage ;
      
         }

  
}
-------------------------------------------
am going in rightway to achive unshare a record using apex and vf ?

Thanks
Hi am tryong to share one job object record to one user using apex  
Job__c is object in that name is one text field   User is one object
 am passing record id to command link but its not working please help on this:

i tryed using pageblock table and datatable but user id un able to pass to controler or takeing first values from select list takeing as default values

vf page
----------------------------------------------------------------------------

<apex:page standardController="Job__c"   extensions="Jobformation1usercon">
    <apex:form >
                <apex:selectList size="1" value="{!jobst }" multiselect="false">
                    <apex:actionSupport event="onchange" reRender="table,opt" />
                    <apex:selectOptions value="{!Job}"> </apex:selectOptions>
                </apex:selectList>
    
                 <apex:outputText id="opt" value="{!jobst }"></apex:outputText>
      
                <apex:selectList size="1" value="{!selectedVal}" multiselect="false">
                <apex:actionSupport event="onchange" reRender="table,opt1" />
                    <apex:selectOptions value="{!Value}">
                    </apex:selectOptions>
                </apex:selectList>
                <apex:outputText id="opt1" value="{!selectedVal}"></apex:outputText>
                    <apex:commandLink action="{!manualShareRead}" value="Share" id="table">
                    <apex:param name="id" value="{!Job__c.id}"/>                 
                </apex:commandLink>
           
     </apex:form>
</apex:page>
-------------------------------------------------------------------------------------------
apex page
---------------------------------------------------
public class Jobformation1usercon
{
 
    
         List<user> con1= new List<user>(); 
         public job__c j {get;set;}
         Public List<string> usertselect{get;set;}
         public string jobst { get;set;}
         public user gp {get;set;}
         public boolean nojb{get;set;}
         public String selectedVal{get;set;}
         public List<job__C> joblist {get;set;}
         public Jobformation1usercon(ApexPages.StandardController controller)
       
       {
           Id id = System.currentPageReference().getParameters().get('id');
     
        }
    public List<SelectOption> getJob()
     {  
         List<SelectOption> option = new List<SelectOption>();
             
        for(job__c j: [Select id,name From  job__c])
         {
         
             option.add(new SelectOption(j.name,j.name));
             system.debug('option value is '+option);
            
         }
         return option;     
    }
     public List<SelectOption> getValue()
     {  
         List<SelectOption> option = new List<SelectOption>();
             
        for(user gp: [Select id,name From  user  ])
         {
         
             option.add(new SelectOption(gp.name,gp.name));
             system.debug('option value is '+option);
            
         }
         return option;     
    }
                
       public PageReference manualShareRead()
           {
             
               Id id = System.currentPageReference().getParameters().get('id');
               system.debug('Id Value is'+id);
               system.debug('aaaaaaaaaaaaaaaaaaaaaa'+selectedVal);
               con1 = [select id from user where name=:selectedVal];
               system.debug('PGList value is'+con1);
               Job__Share jobShr  = new Job__Share(); 
               jobShr.ParentId = id;
               jobShr.UserOrGroupId = con1[0].id;
               jobShr.AccessLevel = 'Read';
               jobShr.RowCause = Schema.Job__Share.RowCause.Manual;
              
             Database.SaveResult sr = Database.insert(jobShr,false);
              system.debug('sr value is'+sr);
      
             if(sr.isSuccess())
            {
               system.debug('sr.isSuccess() value:'+sr.isSuccess());
                  system.debug('if sr.isSuccess() block');
               PageReference nextpage = new PageReference('/apex/CustomTeam?id='+id);
             
                return nextpage;
               }
           else {
                  system.debug('inner else sr.isSuccess() block');
                     Database.Error err = sr.getErrors()[0];
                     if(err.getStatusCode() == StatusCode.FIELD_FILTER_VALIDATION_EXCEPTION  && 
                     err.getMessage().contains('AccessLevel')){
                      system.debug(' iner if sr.isSuccess() block');
                      PageReference nextpage = new PageReference('/apex/CustomTeam?id='+id);
                return nextpage;
            }
             else
             {
                      system.debug('outer else sr.isSuccess() block');
               PageReference nextpage = new PageReference('/apex/CustomTeam?id='+id);
                    return nextpage;
               }
             }
         
         }
  
  
       
     }
Hi    for example role hierarchy  CEO----> projectmanager ---->projectlead 

if am sharing a record with projectmanager only CEO and Projectmanger able to see that record not projectlead How to achive this functionality using apex and visual force any ideas  will be appreciated thanks 
am able share a record to user using apex how to unshare a record using apex

here is my code:

vf page
------------------------------------------------------
<apex:page standardController="Job__c"   extensions="Jobformation1usercon">
    <apex:form >
                <apex:selectList size="1" value="{!jobst }" multiselect="false">
                    <apex:selectOptions value="{!Job}"> </apex:selectOptions> 
                     <apex:actionSupport event="onchange" reRender="table,opt1" />
                </apex:selectList>
    
                <apex:selectList size="1" value="{!selectedVal}" multiselect="false">
                <apex:actionSupport event="onchange" reRender="table,opt1" />
                    <apex:selectOptions value="{!Value}">
                    </apex:selectOptions>
                </apex:selectList>
               
                <apex:outputText id="opt12" value="{!selectedVal}"></apex:outputText>
               
               <apex:commandLink action="{!manualShareRead}" value="Share" id="opt1">
                </apex:commandLink>
           
     </apex:form>
</apex:page>

----------------------------------------------------------------------
apex page
----------------------------------------------------------------------------------------
public class Jobformation1usercon
{
 
    
         List<user> con1= new List<user>(); 
         public job__c j {get;set;}
         Public List<string> usertselect{get;set;}
         public string jobst { get;set;}
         public string val{ get;set;}
         public user gp {get;set;}
         public boolean nojb{get;set;}
         public String selectedVal{get;set;}
         public List<job__C> joblist = new List<job__C>();
         public Jobformation1usercon(ApexPages.StandardController controller)
        {
        }
  
    public List<SelectOption> getJob()
     {  
         List<SelectOption> option = new List<SelectOption>();
             
        for(job__c j: [Select id,name From  job__c])
         {
         
             option.add(new SelectOption(j.name,j.name));
             system.debug('option value is '+option);
            
         }
         return option;     
    }
     public List<SelectOption> getValue()
     {  
         List<SelectOption> option = new List<SelectOption>();
             
        for(user gp: [Select id,name From  user  ])
         {
         
             option.add(new SelectOption(gp.name,gp.name));
             system.debug('option value is '+option);
            
         }
         return option;     
    }
                
       public PageReference manualShareRead()
           {
             
               joblist = [select id from job__C where name=:jobst];
               con1 = [select id from user where name=:selectedVal];
               system.debug('PGList value is'+con1);
               system.debug('PGList value is'+joblist);
               Job__Share jobShr  = new Job__Share(); 
               jobShr.ParentId = joblist[0].id;
               jobShr.UserOrGroupId = con1[0].id;
               jobShr.AccessLevel = 'Read';
               jobShr.RowCause = Schema.Job__Share.RowCause.Manual;
              
             Database.SaveResult sr = Database.insert(jobShr,false);
              system.debug('sr value is'+sr);
      
             if(sr.isSuccess())
            {
               system.debug('sr.isSuccess() value:'+sr.isSuccess());
                  system.debug('if sr.isSuccess() block');
               PageReference nextpage = new PageReference('/apex/CustomTeam?id='+joblist[0].id);
             
                return nextpage;
               }
           else {
                  system.debug('inner else sr.isSuccess() block');
                     Database.Error err = sr.getErrors()[0];
                     if(err.getStatusCode() == StatusCode.FIELD_FILTER_VALIDATION_EXCEPTION  && 
                     err.getMessage().contains('AccessLevel')){
                      system.debug(' iner if sr.isSuccess() block');
                      PageReference nextpage = new PageReference('/apex/CustomTeam?id='+joblist[0].id);
                return nextpage;
            }
             else
             {
                      system.debug('outer else sr.isSuccess() block');
               PageReference nextpage = new PageReference('/apex/CustomTeam?id='+joblist[0].id);
                    return nextpage;
               }
             }
         
         }
  
  
       
     }


-------------------------------
here job__c is object name is one text field  am shring a reord to one user here  user is one object  .

if  i want to un share want i need to do please help on this

thanks
hareesh