• Susanta Chakraborty
  • NEWBIE
  • 20 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 14
    Replies
Hello Team
We would like to hire a developer with sound knowledge of apex class and triggers along with deployment knowledge from sandbox to production. We need basically as a consultant for around 3 months, location will be Chennai. Please reach out to these contact nos asap.

Anup Roy: 9331278800
Susanta Chakraborty: 9903165998
How to use Urlfor function in the existing code
/apex/SDOC__SDCreate1?id={!Staff__c.Id}&Object=Staff__c
Hello

I need one quick help from you. Today I uninstalled the Sdoc app from our production and reinstall it for setting Sdoc number count 0 which I usually does in every end of FY. Everything got back except one problem. Whenever I generate field staff contract or anything through Sdoc template from any module getting the error msg.
"The link you followed isn’t valid. This page requires a CSRF confirmation token. Report this error to your Salesforce administrator."

As for example: There is one button called "Generate staff contract" in staff contract module page layout and its assign this code...
/apex/SDOC__SDCreate1?id={!Staff_Contract__c.Id}&Object=Staff_Contract__c


Also in Sdoc module I have enlisted the particular module in "related to type field" picklist. It usually works but now It doesn't.

Could you plss quickly let me know what went wrong and what will be the solution?
Hi Team
I have one object called Staff contract which linked with one another object called Staff. There is one apex class which restrcit all staff contracts from normal user except admin. Logic is..
if UserID!=OwnerID then no one can see other's staff contracts.
Now problem is, in staff contract objects, there are 2 record types, one is Staff and another one is Field staff. I want to open all field staff contracts for each and every profile.
My question is how to restrict staff contracts in respect of record type. I am attaching the entire class, it will be helpful if anyone can modify the class as per my criteria.

Here is the class...
// Comments:    [Controller for Insert Staff Contract Sharing records.]
Public Class ctrlAddStaffContractSharing{
        
    //List for Staff Contract sharing records.
    List<Staff_Contract__Share> lstStaffContShares = new List<Staff_Contract__Share>();
    
    //List of Staff Contract records.
    List<Staff_Contract__c> lstStaffCont = new List<Staff_Contract__c>();   
     
    //lstGroup will enclose user record which has name ED and HR Head.
    List<Group> lstGroup = [SELECT ID FROM GROUP WHERE DeveloperName = 'ED_and_HR_Head' LIMIT 1];
    
    Public map<Id,User> mapUser = new map<Id,User>();
    Public map<String,String> mapStaff = new map<String,String>();
      
    
    Public void AddStaffContSharing(SET<ID> setStaffContIds){
    
      //Fill Performance Evaluation list.
        lstStaffCont = new List<Staff_Contract__c>([SELECT ID,Name,OwnerId,Staff__c FROM Staff_Contract__c where id in :setStaffContIds]);

        //Delete existing sharing records of Performance Evaluations
        List<Staff_Contract__Share> lstStaffContShareRemove = [SELECT ID,ParentId,RowCause 
                                                                FROM Staff_Contract__Share 
                                                                WHERE RowCause = 'Manual' AND ParentId in :setStaffContIds];
                                                                
        System.debug(lstStaffContShareRemove);                                                        
                                                                
        If(lstStaffContShareRemove.size() > 0)
         Delete lstStaffContShareRemove;
        
        Set<Id> setGroupMemberUserId = New Set<Id>();
        Map<Id,GroupMember> MapGroupMembers;
        if(lstGroup.size()>0){            
            List<GroupMember> lstGroupMember = [Select UserOrGroupId, GroupId From GroupMember Where GroupId =: lstGroup[0].Id];
            if(lstGroupMember.size() > 0){
                for(GroupMember objGM: lstGroupMember){
                    setGroupMemberUserId.Add(objGM.UserOrGroupId);
                }
            }            
        }
        
        for(Staff_Contract__c objStaffCont:lstStaffCont){
            
            Set<Id> setShareTo = New Set<Id>();
           if(lstGroup.size()>0 && setGroupMemberUserId.size()> 0 && setGroupMemberUserId.contains(objStaffCont.OwnerId) == false)
            setShareTo.Add(lstGroup[0].ID);
             
             //Sharing with Staff Owner
            setShareTo.Add(mapStaff.get(objStaffCont.Staff__c));
            
            //Sharing with Staff Owners Manager
            if(mapStaff.containskey(objStaffCont.Staff__c))
             if(mapUser.containskey(mapStaff.get(objStaffCont.Staff__c)))
               if(mapUser.get(mapStaff.get(objStaffCont.Staff__c)).ManagerId != null)
                 setShareTo.Add(mapUser.get(mapStaff.get(objStaffCont.Staff__c)).ManagerId);
                         
                                 
          for(Id objSharetoid : setShareTo){
                //Create a new Performance_Evaluation__Share record to be inserted in to the lstPEShares.
             Staff_Contract__Share objStaffContshare = new Staff_Contract__Share(
                    ParentId = objStaffCont.Id,
                    UserOrGroupId = objSharetoid,
                    AccessLevel = 'Edit');
                lstStaffContShares.ADD(objStaffContshare);
            }
        }
    
        //Insert all of the newly created Share records and capture save result
        Database.SaveResult[] StaffContShareInsertResult = Database.insert(lstStaffContShares,false);
       
            
    }  
    
    Public ctrlAddStaffContractSharing(){
    
      for(User usr : [Select Id, Name, ManagerId,DelegatedApproverId from User])
       mapUser.put(usr.Id,usr);
       
      for(Staff__c staff : [Select Id, Name, OwnerId from Staff__c])
        mapStaff.put(staff.Id,staff.OwnerId);
             
    }   
    
   
}
Hi Team

Could anyone write the codes which help me to restrict record type in list view in one object.
I have one object called "Person" which has 4-5 record types and 4-5 page layout assign with particular record type. There are 2 record types, which are "Staff" & "Limited Staff". Staff record type has similar called page layout with so many fields and Limited staff record type also has similar page layout which restrict with some fields.

Now I want if User ID <> Owner ID then Limited staff record type and page layout should open from list view, other-wise Staff record type and page layout should open for the  true critiria.... User ID=Owner ID.

Please let me know if anyone can help me out. I am not very familiar with apex codes
Hi Team

I would like to know, how a checkbox field automatically uncheck based on some date criteria through workflow time trigger. Basically logic should be..

If date_field_c + 1=today() then field update happen (checkbox_field_c = unchecked)

I already implemented one workflow but it did not work well. I am mentioning my workflow logic below:-
RecordType.Name = "Field Staff" && ((End_Date__c + 1) = today())

Field update:-
New Field ValueFalse

Please let me know how I can resolve the issue.
Can I make some certain fileds invisible in one object using validations?? The logic should be if OwnerID<>userID then some fields will not be visible for others. Is that possible without using apex class and triggers??
Let me know please as soon as possible
Can I make some certain fileds invisible in one object using validations?? The logic should be if OwnerID<>userID then some fields will not be visible for others. Is that possible without using apex class and triggers??
Let me know please as soon as possible
How to use Urlfor function in the existing code
/apex/SDOC__SDCreate1?id={!Staff__c.Id}&Object=Staff__c
Hello

I need one quick help from you. Today I uninstalled the Sdoc app from our production and reinstall it for setting Sdoc number count 0 which I usually does in every end of FY. Everything got back except one problem. Whenever I generate field staff contract or anything through Sdoc template from any module getting the error msg.
"The link you followed isn’t valid. This page requires a CSRF confirmation token. Report this error to your Salesforce administrator."

As for example: There is one button called "Generate staff contract" in staff contract module page layout and its assign this code...
/apex/SDOC__SDCreate1?id={!Staff_Contract__c.Id}&Object=Staff_Contract__c


Also in Sdoc module I have enlisted the particular module in "related to type field" picklist. It usually works but now It doesn't.

Could you plss quickly let me know what went wrong and what will be the solution?
Hi Team

Could anyone write the codes which help me to restrict record type in list view in one object.
I have one object called "Person" which has 4-5 record types and 4-5 page layout assign with particular record type. There are 2 record types, which are "Staff" & "Limited Staff". Staff record type has similar called page layout with so many fields and Limited staff record type also has similar page layout which restrict with some fields.

Now I want if User ID <> Owner ID then Limited staff record type and page layout should open from list view, other-wise Staff record type and page layout should open for the  true critiria.... User ID=Owner ID.

Please let me know if anyone can help me out. I am not very familiar with apex codes
Hi Team

I would like to know, how a checkbox field automatically uncheck based on some date criteria through workflow time trigger. Basically logic should be..

If date_field_c + 1=today() then field update happen (checkbox_field_c = unchecked)

I already implemented one workflow but it did not work well. I am mentioning my workflow logic below:-
RecordType.Name = "Field Staff" && ((End_Date__c + 1) = today())

Field update:-
New Field ValueFalse

Please let me know how I can resolve the issue.
Can I make some certain fileds invisible in one object using validations?? The logic should be if OwnerID<>userID then some fields will not be visible for others. Is that possible without using apex class and triggers??
Let me know please as soon as possible