• Nitin Sharma
  • NEWBIE
  • 165 Points
  • Member since 2015


  • Chatter
    Feed
  • 2
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 24
    Questions
  • 88
    Replies
Hello,

I have a object which is public read/write.
I have a validation rule like below which prevents modification of a custom field if the person is not the owner of the record.
Validation rule is like below
ISCHANGED( Custom_field1__c ) &&  $User.Id  <>  OwnerId

I want to add in this validation rule that the person with XYZ profile will ALSO be able to modify the custom field.

How can i add condition ?
thansk for suggestion !
  • August 17, 2016
  • Like
  • 0
Hello,

I would like to have a feature to control who have access to click on Report Tab. Ideally those user without the access should not even see the Salesforce Report Tab.

My use case is that everyone should be able to view all custom object's records, but only management has access to the Report Tab.

Thanks.
Damon
I have 2 process builder which are updating account same field.
 Process builder 1 Scenario - On account when 1 child sms record created and will send one SMS to a customer when sms sent, through process builder it will update the account opt-in status field (number filed) to 0.
Process builder 2 Scenario -  When Customer receive SMS and if reply back as Yes then system will create one record and Update account opt-in status field to '1' .

Issue is before completing the status of child record if customer reply quick in a difference of second it will update opt-in status to 1 and then as per 1st process builder it update opt-in status to 0. This is happens in second of time and in process builder we cannot control the flow. 
I want system will update to '0' and when customer reply YES update to '1'

User-added image

Can anyone suggest me any solution?



 

Scenario: I need to update some field based on territory assigned an account. I have written a Trigger on after update but it didn’t work as nothing is updated on the account so my trigger didn't work.
 
Hi All,

I want to create a button on the lightning home page, onclick on the button it will redirect to the dashboard. 
I created a dashboard on the lightining homepage but I want functionality that instead of dashboard button should be there, while user click on the button it will redirect the user to dashboard. 

How can we achieve this functionality? User-added image
I created vf page and controller but while I am searching, getting an error 
''line 1:56 no viable alternative at character '"'
Error is in expression '{!search}' in component <apex:commandButton> in page testactiveacc: Class.activeAccount.search: line 18, column 1
"

Vf page
<apex:page standardController="Account" extensions="activeAccount" tabStyle="Account">  
  <apex:form > 
  <apex:sectionHeader title="User Global Search" subtitle="Result"/> 
  <apex:pageBlock >
      <apex:pageBlockSection columns="1">
          <apex:pageBlockSectionItem >
              <label>Quick Search</label>
              <apex:outputPanel >
                  <apex:inputText value="{!searchstring}" label="Input"/>
                  <apex:commandButton value="Search records" action="{!search}" reRender="pgId1,pgId2" status="ajaxId"/>
                  &nbsp;<apex:actionStatus startText="Searching..." id="ajaxId"></apex:actionStatus>
              </apex:outputPanel>
          </apex:pageBlockSectionItem>
      </apex:pageBlockSection>
  </apex:pageBlock>
  
  
    
     
   <apex:pageBlock title="Search Active Result" id="pgId1">  
    <apex:pageblockTable value="{!acc}" var="a">  
     <apex:column headerValue="Name" >  
      <apex:outputlink value="https://ap1.salesforce.com/{!a.id}">{!a.Name}</apex:outputlink>       
     </apex:column> 
     <apex:column headerValue="Active" >  
       <apex:outputlink >{!a.Active__c}</apex:outputlink>
     </apex:column> 
     
     <apex:column value="{!a.id}"/>  
    </apex:pageBlockTable>     
   </apex:pageBlock>   
   
   <apex:pageBlock title="Search Inactive Result" id="pgId2">  
    <apex:pageblockTable value="{!acc1}" var="a">  
     <apex:column headerValue="Name" >  
      <apex:outputlink value="https://ap1.salesforce.com/{!a.id}">{!a.Name}</apex:outputlink>       
     </apex:column> 
    <apex:column headerValue="Active" >  
       <apex:outputlink >{!a.Active__c}</apex:outputlink>
     </apex:column>
     
     <apex:column value="{!a.id}"/>  
    </apex:pageBlockTable>     
   </apex:pageBlock>   
   
  </apex:form>  
 </apex:page>

Controller class
public with sharing class activeAccount {
  
   public list <Account> acc {get;set;}
   public list <Account> acc1 {get;set;}
   public string searchstring {get;set;} 
  
   public string value1 {get;set;} 
   
   
    
   public activeAccount (ApexPages.StandardController controller) {
     
   }  
   public void search(){  
     if(searchstring != null && searchstring != '' ){  
     string searchquery='select Name, id,Active__c from Account where Active__c ="Yes" AND Name like \'%'+searchstring+'%\'  Limit 10';  
       string searchquery1='select Name, id,Active__c from Account where Active__c ="No" AND Name like \'%'+searchstring+'%\'  Limit 10';  
     acc = Database.query(searchquery); 
     acc1 = Database.query(searchquery1); 
     }
     }
     
    
   }
Code not working. Can any one help.
 
Req.- On account object, having 2 fields 1st- D1 and 2nd- D2.
While inserting or updating account if D1 != D2 then it will compare the D2 value to D1 values from all org account and if any record found then that account having all contacts assigned to Inserting or updating an account.  
Suppose parent account having 3 territories then all 3 territories assigned to the child's account.  
How to hide "Save & New Task" button from task page layout.
User-added image
I want to deploy custom picklist value from one sandbox to another, I am using change set but it not working . 
Any suggestion.

Thanks,
Nitin Sharma
I am trying to write a trigger in my Performance edition but its show that in Active enviorment you can't create it. what is the reason behind this.
Any help.

Thanks,
Nitin Sharma
Batch class
global class BirthdayNotificationBatch Implements Database.Batchable <sObject> {
    global Database.queryLocator start(Database.BatchableContext bc) {
        Date tody = system.today();
        String SOQL = 'SELECT Id, Name, Email__c FROM Contact WHERE DAY_IN_MONTH(Birthdate) = ' + 
                      tody.day() +  ' AND CALENDAR_MONTH(Birthdate) = ' + tody.month();
        return Database.getQueryLocator(SOQL);
    }

    global void execute(Database.BatchableContext bc, List<Contact> listContacts) {
        List<Messaging.SingleEmailMessage> mailList = new List<Messaging.SingleEmailMessage>();
        for(Contact c : listContacts) {
            List<String> toAddresses = new List<String>{c.Email};           
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            mail.setToAddresses(toAddresses);
            mail.setSubject('Happy Birthday');
            String messageBody = '<html><body>Hi ' + c.Name + ',<br/>Happy Birthday.<br/>Many More Happy '+
                                 'Returns of the day.<br/><br/><b>Regards,</b><br/>Admin</body></html>';
            mail.setHtmlBody(messageBody); 
            mailList.add(mail);          
        } 
        Messaging.sendEmail(mailList);        
    }

    global void finish(Database.BatchableContext bc) {
    }
}
Schedule class
global class ScheduleBatch Implements Schedulable {
    global void execute(SchedulableContext sc){
        BirthdayNotificationBatch sb = new BirthdayNotificationBatch();
        Database.executeBatch(sb);
    }
    ScheduleBatch my = new ScheduleBatch();
    String str = '0 30 11 * 5 ?';
    System.schedule('sb', str, my);
    
}
But its not working.
Anyone can solve this issue.

Thanks
Nitin Sharma

 
Create a VF page with custom controller to search for all accounts on the basis of name.
If we select one of the account and click on create contact then it should be redirected to a new VF Page to create a contact for that account. When I click on save then I should be redirected to the contact detail page.
<apex:page standardController="Account" extensions="accountSearch" >
    <apex:include pageName="CreateContact"/>
 <apex:form > 
  <apex:sectionHeader title="User Global Search" subtitle="Result"/> 
  <apex:pageBlock >
      <apex:pageBlockSection columns="1">
          <apex:pageBlockSectionItem >
              <label>Quick Search</label>
              <apex:outputPanel >
                  <apex:inputText value="{!searchstring}" label="Input"/>
                  <apex:commandButton value="Search records" action="{!search}" reRender="accPgId" status="ajaxId"/>
                  <apex:commandButton value="create contact" action="{! create}" reRender="ContactPgId" />>
                  &nbsp;<apex:actionStatus startText="Searching..." id="ajaxId"></apex:actionStatus>
              </apex:outputPanel>
          </apex:pageBlockSectionItem>
      </apex:pageBlockSection>
  </apex:pageBlock>
     
      <apex:pageBlock title="Search Account Result" id="accPgId" >  
    <apex:pageblockTable value="{!acc}" var="a">  
      
     <apex:column headerValue="Name" >  
       <apex:outputlink >{!a.Name}</apex:outputlink>
         <apex:inputCheckbox value="{! a.Name}">
             </apex:inputcheckbox>
     </apex:column> 
     <apex:column headerValue="Phone" >  
       <apex:outputlink >{!a.Phone}</apex:outputlink>
     </apex:column>
     
    </apex:pageBlockTable>     
   </apex:pageBlock>  
    </apex:form>
</apex:page>

 
Scenario: Email field on lead object. When user create a record email id field is mandatory but when user edit or update record its not mandatory .
how can i achive this with one validation rule.
Scenario :
On Account there is checkbox named Active.
Build VF page that will show table with account details (fields).
There are 2 buttons on the same page i.e. Activate and Deactivate.
User will select some accounts from the given table and clicks Activate buttons and this makes Active checkbox true for selected accounts. Same will be the logic for Deactivate button for deactivating account.
scenario: owner of the record has changed to someone and get Read access to previous owner. My code below:
trigger ShareRecord on Opportunity (after update) {
List<Opportunity> opptylist = new List<Opportunity>();
    for(Opportunity oppty : trigger.new){
        if(oppty.OwnerId != trigger.oldMap.get(oppty.Id).OwnerId){
            OpportunityShare opptyshare = new OpportunityShare();
            opptyshare.UserorGroupId = trigger.oldMap.get(oppty.Id).OwnerId;
            opptyshare.ParentId = oppty.Id;
            opptyshare.AccessLevel = 'READ';
            
            opptylist.add(opptyshare);
        }
    }
    insert opptylist;
}

but didn't work.

Thanks,
Nitin
 
this is my code but its not woking. any one can help

global class LeadProcessor implements Database.Batchable<sObject> {
    global Database.QueryLocator start(Database.BatchableContext bc){
          String query= 'SELECT Name, LeadSource from Lead';
        return Database.QueryLocator(query);
    }
    global void execute(Database.BatchableContext bc, List<Lead> scope){
        
        for(Lead l: scope){
            l.LeadSource ='Dreamforce';
           
        }
        update scope;
    }
    global void finish(Database.BatchableContext bc){
        
    }
}
Showig error " Challenge Not yet complete... here's what's wrong:
An external object with the API name Phone_Plan__x does not exist" I checked many time Phone_Plan__x already exist.
When i am working on Developer console there are showing an error always. Error title is FIELD_INTEFRITY_EXCEPTION.
Please provide help.
FIELD_INTEFRITY_EXCEPTION
Failed to create createContainerMember for containerId=1dc280000006iaBAAQ: This container member belongs to a container that currently has an unfinished save request with deploymentId=1dr28000002te6r. You may not modify any members in this container until it completes.: Metadata Container ID

Thanks
Nitin Sharma
I created vfpage and it saved but no result displayed.My code given below:
VFpage:
<apex:page standardController="Account"  extensions="Searchclass" tabStyle="User">  
  <apex:form > 
  <apex:sectionHeader title="User Global Search" subtitle="Result"/> 
  <apex:pageBlock >
      <apex:pageBlockSection columns="1">
          <apex:pageBlockSectionItem >
              <label>Quick Search</label>
              <apex:outputPanel >
                  <apex:inputText value="{!searchstring}" label="Input"/>
                  <apex:commandButton value="Search records" action="{!search}" reRender="pgId" status="ajaxId"/>
                  &nbsp;<apex:actionStatus startText="Searching..." id="ajaxId"></apex:actionStatus>
              </apex:outputPanel>
          </apex:pageBlockSectionItem>
      </apex:pageBlockSection>
  </apex:pageBlock>
  
  
    
     
   <apex:pageBlock title="Search Account Result" >  
    <apex:pageblockTable value="{!acc}" var="a">  
      
     <apex:column headerValue="Name" >  
       <apex:outputlink >{!a.Name}</apex:outputlink>
     </apex:column> 
     <apex:column headerValue="Phone" >  
       <apex:outputlink >{!a.Phone}</apex:outputlink>
     </apex:column>
     
    </apex:pageBlockTable>     
   </apex:pageBlock>  

    <apex:pageBlock title="Search Contact Result" >  
    <apex:pageblockTable value="{!con}" var="c">  
     
     <apex:column headerValue="Name" >  
       <apex:outputlink >{!c.Name}</apex:outputlink>
     </apex:column> 
     <apex:column headerValue="Phone" >  
       <apex:outputlink >{!c.Phone}</apex:outputlink>
     </apex:column>
    
    </apex:pageBlockTable>     
   </apex:pageBlock>  
   
   
    <apex:pageBlock title="Search Opportunity Result" >  
    <apex:pageblockTable value="{!opty}" var="o">  
   
     <apex:column headerValue="Name" >  
       <apex:outputlink >{!o.Name}</apex:outputlink>
     </apex:column> 
     <apex:column headerValue="StageName" >  
       <apex:outputlink >{!o.StageName}</apex:outputlink>
     </apex:column>
     
    </apex:pageBlockTable>     
   </apex:pageBlock>  
  </apex:form>  
 </apex:page>

Extension class:
public with sharing class Searchclass {
  
   public list <Account> acc {get;set;}
   public list<Contact> con{get;set;}
   public list<Opportunity> opty{get;set;}
   public string searchstring {get;set;} 
   public string value1 {get;set;} 
   
   
    
   public Searchclass(ApexPages.StandardController controller) {
     
   }  
   public void search(){  
     if(searchstring != null && searchstring != '' ){  
     string searchquery='select Name, Phone from Account where Name like \'%'+searchstring+'%\'  Limit 10';  
     string searchquery1='select Name, Phone from Contact where Name like \'%'+searchstring+'%\'  Limit 10';
     string searchquery2='select Name, StageName from Opportunity where Name like \'%'+searchstring+'%\'  Limit 10';
     acc= Database.query(searchquery); 
     con= Database.query(searchquery1); 
     opty= Database.query(searchquery2); 
     }
     }
      }

Plz help
When i am working on Developer console there are showing an error always. Error title is FIELD_INTEFRITY_EXCEPTION.
Please provide help.
FIELD_INTEFRITY_EXCEPTION
Failed to create createContainerMember for containerId=1dc280000006iaBAAQ: This container member belongs to a container that currently has an unfinished save request with deploymentId=1dr28000002te6r. You may not modify any members in this container until it completes.: Metadata Container ID

Thanks
Nitin Sharma

Scenario: I need to update some field based on territory assigned an account. I have written a Trigger on after update but it didn’t work as nothing is updated on the account so my trigger didn't work.
 
I created vf page and controller but while I am searching, getting an error 
''line 1:56 no viable alternative at character '"'
Error is in expression '{!search}' in component <apex:commandButton> in page testactiveacc: Class.activeAccount.search: line 18, column 1
"

Vf page
<apex:page standardController="Account" extensions="activeAccount" tabStyle="Account">  
  <apex:form > 
  <apex:sectionHeader title="User Global Search" subtitle="Result"/> 
  <apex:pageBlock >
      <apex:pageBlockSection columns="1">
          <apex:pageBlockSectionItem >
              <label>Quick Search</label>
              <apex:outputPanel >
                  <apex:inputText value="{!searchstring}" label="Input"/>
                  <apex:commandButton value="Search records" action="{!search}" reRender="pgId1,pgId2" status="ajaxId"/>
                  &nbsp;<apex:actionStatus startText="Searching..." id="ajaxId"></apex:actionStatus>
              </apex:outputPanel>
          </apex:pageBlockSectionItem>
      </apex:pageBlockSection>
  </apex:pageBlock>
  
  
    
     
   <apex:pageBlock title="Search Active Result" id="pgId1">  
    <apex:pageblockTable value="{!acc}" var="a">  
     <apex:column headerValue="Name" >  
      <apex:outputlink value="https://ap1.salesforce.com/{!a.id}">{!a.Name}</apex:outputlink>       
     </apex:column> 
     <apex:column headerValue="Active" >  
       <apex:outputlink >{!a.Active__c}</apex:outputlink>
     </apex:column> 
     
     <apex:column value="{!a.id}"/>  
    </apex:pageBlockTable>     
   </apex:pageBlock>   
   
   <apex:pageBlock title="Search Inactive Result" id="pgId2">  
    <apex:pageblockTable value="{!acc1}" var="a">  
     <apex:column headerValue="Name" >  
      <apex:outputlink value="https://ap1.salesforce.com/{!a.id}">{!a.Name}</apex:outputlink>       
     </apex:column> 
    <apex:column headerValue="Active" >  
       <apex:outputlink >{!a.Active__c}</apex:outputlink>
     </apex:column>
     
     <apex:column value="{!a.id}"/>  
    </apex:pageBlockTable>     
   </apex:pageBlock>   
   
  </apex:form>  
 </apex:page>

Controller class
public with sharing class activeAccount {
  
   public list <Account> acc {get;set;}
   public list <Account> acc1 {get;set;}
   public string searchstring {get;set;} 
  
   public string value1 {get;set;} 
   
   
    
   public activeAccount (ApexPages.StandardController controller) {
     
   }  
   public void search(){  
     if(searchstring != null && searchstring != '' ){  
     string searchquery='select Name, id,Active__c from Account where Active__c ="Yes" AND Name like \'%'+searchstring+'%\'  Limit 10';  
       string searchquery1='select Name, id,Active__c from Account where Active__c ="No" AND Name like \'%'+searchstring+'%\'  Limit 10';  
     acc = Database.query(searchquery); 
     acc1 = Database.query(searchquery1); 
     }
     }
     
    
   }
Code not working. Can any one help.
 

I need custom picklist fields on Account to be autopopulated on creating New Account. I have written trigger for this. It is working on before update but not working for Before insert. Please help.
User-added image
I am trying to use Process Building to update a date field on a custom object, based on the date field being updated on another custom object. Have tried several methods and they do not work.

By the way, right now we have a formula field to update the date field, and it works. But formula fields do not appear when in edit mode, so it is a major inconvenience to our customer support team.

I tried using Process as either "Conditions are met: when the field is changed" or when the "Formual evaluates to true, using the "ischanged" formula". Also tried to update the field from Obj 1 or from Obj 2 (since I have a formula field on Obj 2). Tried doing an update as a Reference and as a Formula But the process building will not update the date field on Obj 2 when the date field is changed on Obj 1.

Any suggestions?
Hi
I have userA who has sysadmin profile and role=Project Manager.
Another userB who has role=CEO and some profile.

Now userA creates a few records and these are automatically shared with userrB because he has a higher role.
Now I want to restrict access to userB to only READ, I want to prevent him from having EDIT/DELETE/SHARING options.

Is this possible? Please let me know.

Thanks
Pooja
 
Hi Team,

Can any one please help me to create a trigger for below senario.

Object: Task
if Task.Support Team Request = AE Support Request
then{
if Task.created by.Pole = NA or North America then set Task.project= AE NA or Project id= xxxx
if Task.created by.Pole = China then set Task.project= AE China or Project id= xxxx1
if Task.created by.Pole = APAC then set Task.project= AE APAC or Project id= xxxx2
if Task.created by.Pole = EMEA or MEA then set Task.project= AE EMEA or Project id= xxxx3
if Task.created by.Pole = LATAM then set Task.project= AE LATAM or Project id= xxxx4
}

Thanks in Advance
Hi,

I have created a Time based workflow to trigger email 5 days later from the Case record Opened Date. On the condition based on when Priority= Normal AND Status != Closed,swap-Return . then it should trigger. Elase it should not trigger.

But even after the case is Closed the email is getting triggered on the 5th day.User-added imageUser-added image
Put your thoughts on this.