• Grazitti Team
  • SMARTIE
  • 1874 Points
  • Member since 2014
  • Grazitti Interactive
  • http://www.grazitti.com/

  • Chatter
    Feed
  • 61
    Best Answers
  • 1
    Likes Received
  • 1
    Likes Given
  • 2
    Questions
  • 318
    Replies
I have to send outobund http request by using PATCH method, but salesforce httprequest.setMethod(), not support PATCH method, So please help me how can I achive this?
Hi All,

1 -Is there any limits governing for rest api callout while its transferring data to other service?
Like I have SF org and one is Heroku Web app. If I am sending request from Heroku to Sf so is there any limitation comes while sending data ?
2- If I am posting some data on SF from Heroku so is there any limitation hits like size of content etc.

Please let me know if anyone know this.

Thanks in advance
Hello,
I have a component that is used by multiple pages, displaying different data (in the same layout) based on the page it is loaded in.
Both the Page and the Component use the same controller, the logic of the component controler is embedded in the page controller logic.
Is there a way for the page to pass its controller name as an attribute to the compoent? It works fine for language but it seems that controller value must be only string between " ".  Any workaround?
Thanks in advance for your help and any idea. Otherwise, I have to create one component to fit each page, just different in their controller name. What I would like is something like:
<apex:page controller=" ControlerForThisPage" >
<c:componentName controller= "ControlerForThisPage" language= "en_US" />     <!--assigning controller value on component -->
<…
</apex :page>
Component :
<apex:component controller= "{ !controller}" language="{ !language}" >  <!--  How to pass ControlerForThisPage here? -->
<apex:attribute name=controller type="string" ..
<apex:attribute name=language  type="strng" ..
<..
</apex:component>
 
Dear all, below is my code which automatically send email notificaitons when a new Event is created. If opportunity is not tagged to Event, I`m getting a System.NullpointerException. Could you please help in understanding what I`m doing wrong? I`m new to Apex 

Apex trigger NotifyOnSiteVist2 caused an unexpected exception, contact your administrator: Visitnotify: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.Visitnotify: line 29, column 1

 
Trigger Visitnotify on Event (after insert){
        
    List<Messaging.SingleEmailMessage> newEmails = new List<Messaging.SingleEmailMessage>();
    List<Id> whatIds = new List<Id>();
    List<Id> createdByIds = new List<Id>();
    for(Event e :Trigger.new)
    {
        createdByIds.add(E.CreatedByID);
        whatIds.add(E.whatId);
    }
    Map<Id, User> users = new Map<Id, User>([SELECT Id, Name from User WHERE Id in :createdByIds]);
    Map<Id, Opportunity> opportunities = new Map<Id, Opportunity>([SELECT Name, Account.Name from Opportunity WHERE Id in :whatIds]);
    for(Event e :Trigger.new){
    
    if(e.whatid != NULL){ 
            String fullTaskURL;
            String Facility;
            Datetime startDate;
            Datetime endDate;
            String Purpose;

            
            // Query to populate CreatedBy name in html template
            Id createdByID = E.CreatedByID;
            String createdByName = users.get(createdByID).Name;
                   
            // Query to populate Opportunity name in html template
            String oppID = E.whatId;  
            String oppName = opportunities.get(oppID).Name;
                                 
        if(E.Site_Visit__C ){
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                
            mail.setSubject(' Alert: A New Visit Record is Created');
            mail.setSaveAsActivity(false);
            mail.setTargetObjectId('00580000005LedR'); 
                                     
            fullTaskURL = URL.getSalesforceBaseUrl().toExternalForm() + '/' + E.Id;
            Facility = E.Facility__c;
            startDate = E.StartDateTime;
            endDate = E.EndDateTime;
            Purpose = E.Purpose_of_Visit__c;
                
   
            //Generate email template
                String emailBody;
                emailBody = '<html><body>Hi ,<br> <br> A New Site Visit Record has been created: <a href="' + fullTaskURL + '">' + E.Id + '</a><br></body></html>' + '<br> Sales VP: '+ createdByName + '<br> Opportunity/Account Name: '+ oppName + '<br> <br> Site/Facility: ' + Facility+ '<br> Purpose of Visit: ' + Purpose +  '<br> Start Date/Time: ' + StartDate +  '<br> End Date/Time: ' +endDate +  '<br> <br> Thank you <br> <br> Salesforce Admin' ;
                mail.setHtmlBody(emailBody );

            newEmails.add(mail);
        }
    }

    messaging.sendEmail(newEmails);
} }

 
When I'm adding script files to a lightning component i'm getting an error as 'script tags only allowed in templates: Source'. Is there another way to add script links to the lightning application?
I have this class :
public with sharing class PdfGeneratorController {

    public PdfGeneratorController(ApexPages.StandardController controller) {

    }


  public ID parentId {get;set;}
  public String pdfName {get;set;}
  public ID factureId {get;set;}

  public PageReference savePdf() {
  
  Facture__c f = [Select Devis__c, Name From Facture__c Where Id = :ApexPages.currentPage().getParameters().get('id')];
  
  factureId = ApexPages.currentPage().getParameters().get('id');
  pdfName = 'Facture '+f.Name;
  parentId = f.Devis__c;

    PageReference pdf = Page.Facture_Puerto_cacao_pdf;
    // add parent id to the parameters for standardcontroller
    pdf.getParameters().put('id',parentId);

    // create the new attachment
    Attachment attach = new Attachment();

    // the contents of the attachment from the pdf
    Blob body;

    try {

        // returns the output of the page as a PDF
        body = pdf.getContent();

    // need to pass unit test -- current bug    
    } catch (VisualforceException e) {
        body = Blob.valueOf('Some Text');
    }

    attach.Body = body;
    // add the user entered name
    attach.Name = pdfName;
    attach.IsPrivate = false;
    // attach the pdf to the account
    attach.ParentId = factureId;
    insert attach;

    // send the user to the account to view results
    return new PageReference('/'+factureId);

  }

}

and th test class :
@isTest
private class Test_PdfGeneratorController {

  static Facture__c fact;

  static {

    fact = new Facture__c();
    fact.Devis__c = '0Q0L0000000AH4m';
    insert fact;

  }

  static testMethod void testPdfGenerator() {

    PageReference pref = Page.Facture_Puerto_cacao_pdf;
    pref.getParameters().put('id',fact.Devis__c);
    Test.setCurrentPage(pref);
    
    // Instantiate standard Controller
        ApexPages.standardController controller = new ApexPages.standardController(fact);

    // Instantiate controller extension
      PdfGeneratorController con = new PdfGeneratorController(controller);


    Test.startTest();

    // populate the field with values
    con.parentId = fact.Id;
    con.pdfName = 'My Test PDF';

    // submit the record
    pref = con.savePdf();

    // assert that they were sent to the correct page
    System.assertEquals(pref.getUrl(),'/'+fact.id);

    // assert that an attachment exists for the record
    System.assertEquals(1,[select count() from attachment where parentId = :fact.Devis__c]);

    Test.stopTest(); 

  }
}

The code coverage is 26%, can you help me please 
Assuming there're User1, User2 and Administrator in the org, can Admin see the data of User1 and User2? How about in API access level, if Admin executes API query, is all users' data queried?

Another question: is the data between User1 and User 2 isolated? That's user1 can't see user2's data?
Hi,

I can't save the apex classes in developer console.When I am trying to save the file this error is occurring.Let me know what will be the problem?

User-added image
  • September 19, 2014
  • Like
  • 0
Hi

I created vfp in that i got valuers through input field and i saved/updated in text field of object,
<apex:inputText label="{!month1}" value="{!amount1}"

i just want to stay my last updated/inserted value in that textfiled. Can any one help me for this!
I received this error when trying to save my trigger in the developer console

An unexpected error has occurred. 207196298-81555 (749494588) for deploymentId=1drn0000000DwsMAAS If this persists, please contact customer support.

Does anyone know what this error means? SF support would not help me with this and I'm not sure what the error means.
<apex:page controller="Pagination_min">
    <apex:form >
        <apex:pageBlock id="pb">
            <apex:pageBlockTable value="{!Accounts}" var="a">
                <apex:column value="{!a.Name}"/>
                <apex:column value="{!a.Type}"/>
                <apex:column value="{!a.BillingCity}"/>
                <apex:column value="{!a.BillingState}"/>
                <apex:column value="{!a.BillingCountry}"/>
            </apex:pageBlockTable>
            <apex:panelGrid columns="7">
                <apex:commandButton status="fetchStatus" reRender="pb" value="|<" action="{!setCon.first}" disabled="{!!setCon.hasPrevious}" title="First Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value="<" action="{!setCon.previous}" disabled="{!!setCon.hasPrevious}" title="Previous Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value=">" action="{!setCon.next}" disabled="{!!setCon.hasNext}" title="Next Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value=">|" action="{!setCon.last}" disabled="{!!setCon.hasNext}" title="Last Page"/>
                <apex:outputText >{!(setCon.pageNumber * size)+1-size}   -    {!IF((setCon.pageNumber * size)>noOfRecords, noOfRecords,(setCon.pageNumber * size))} of {!noOfRecords}</apex:outputText>
                <apex:commandButton status="fetchStatus" reRender="pb" value="Refresh" action="{!refresh}" title="Refresh Page"/>
                <apex:outputPanel style="color:#4AA02C;font-weight:bold">
                    <apex:actionStatus id="fetchStatus" startText="Fetching..." stopText=""/>
                </apex:outputPanel>
            </apex:panelGrid>
        </apex:pageBlock>
    </apex:form>
</apex:page>


class



public  class Pagination_min {
    Public Integer noOfRecords{get; set;}
    Public Integer size{get;set;}
    public ApexPages.StandardSetController setCon {
        get{
            if(setCon == null){
                size = 10;
                string queryString = 'Select Name, Type, BillingCity, BillingState, BillingCountry from Account order by Name';
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(queryString));
                setCon.setPageSize(size);
                noOfRecords = setCon.getResultSize();
            }
            return setCon;
        }set;
    }
    
    Public List<Account> getAccounts(){
        List<Account> accList = new List<Account>();
        for(Account a : (List<Account>)setCon.getRecords())
            accList.add(a);
        return accList;
    }
    
    public pageReference refresh() {
        setCon = null;
        getAccounts();
        setCon.setPageNumber(1);
        return null;
    }
}

i cant undstnd the bold part in the code also

<apex:outputText >{!(setCon.pageNumber * size)+1-size}   -    {!IF((setCon.pageNumber * size)>noOfRecords, noOfRecords,(setCon.pageNumber * size))} of {!noOfRecords}</apex:outputText>

i cudnt get the logic  also in the class  i fail to undsth the bold part

Hi all,

I am using standard controller to show all the fields and fields values of a particular object in VF Page. 

Now I have created one button on the VF page. On click of the button the entire record should be send as an email in XML format. 

I am not getting any way to convert the data into XML. 

Can someone help how can I achieve this requirement.

Thanks,
Manu
I need to save two objects that have parent child relationship , using a single visual force page. And also I need to pass values to the controller from the form both  parent and child object's values. Is there any way to implement this ?
here parent is department and child is employee

vf page
-------------
<apex:page controller="depttoemp">
  <apex:form >
    <apex:pageblock title="dept to emp">
      <apex:pageBlockTable value="{!dept}" var="d">
        <apex:column value="{!d.id}"/>
        <apex:column value="{!d.name}"/>
      </apex:pageBlockTable>
    </apex:pageblock>
  </apex:form>
</apex:page>

controller
--------------
public with sharing class depttoemp {
public list<Department__c> dept{get;set;}
public list<Employee__c> emp{get;set;}
public depttoemp ()
{
string soql='select id,name,(select id,name from Employee__r)from Department__c';
dept=Database.Query(soql);
}
}
im getting this problem
====================
System.QueryException: Didn't understand relationship 'Employee__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.










Hi,

Can any body help me how to show jquery UI dialog in visual force page?

Thanks in advance.
Hi,

I have a number field (Number, 0) but when i put valuee 10000 in it it will diplay it as 10,000 i want to display it without comma.
I have selected number field because i need to select Max number from it and add 1 in Max number for new entry.
Can any body help me how i can do it.

Thanks,
Faraz
Hi Everybody,
       Can anyone tell me how to get all managers id based on the user id??
like user-->manager1-->manager2-->manager3--->manager4 


My code is:
 

public static List<Id> getParrentId(Id i){
        List<Id> ParentUserId=new List<Id>();
        User ur = new User();
        ur = [select Id, Name, ManagerId from User  where Id =: i];
        
        if(ur.ManagerId != null)        
            ParentUserId.addAll(getParrentId(ur.ManagerId));
        return ParentUserId;
     }

But it doesnt get all parent id??
Thanks in advance
Karthick
Hi,

We just want to use the Bcrypt encryption in apex code but we are not getting any standard method to get it encrypted using EncodingUtil class.

WebService that we want to consume makes it compulsory to Bcrypt during authentication process.

NOTE: We dont want to any JS as code will be called from scheduled class.

 Also Crypt function of PHP produces the same result. So, any equivalent of Crypt in php or Bcrypt in java/javascript would work

Thanks!
Hi all,

I am trying to generate a list of auto-complete options using the following code :-

Vf Page :
<apex:input onblur="passSelectValueToController(this.value)" list="{!todoListForDropdown}" html-autocomplete="off" />

Apex Class :
public List<string> gettodoListForDropdown(){
        list<todo__c> getinsertedtodolist = [select id,task__c from todo__c where servicepack__c =: this.RelatedServicePacks];
        Map<String,todo__c> insertedToDoMap = new Map<String,todo__c>();
        for(todo__c todo : getinsertedtodolist)
        {
           insertedToDoMap.put(todo.task__c,new todo__c());
        }
        list<todosdata__c> gettodos = [select id,Name from todosdata__c where Name NOT IN : insertedToDoMap.keyset()];
        list<string> stringValues = new list<String>();
        for(todosdata__c td : gettodos )
        {
            stringValues.add(td.Name);
        }        
        return stringValues;           
    }

By this code, auto complete feature is working fine in Mozilla and chrome but not working in Safari.

Any Help ?? 
Hi,

We just want to use the Bcrypt encryption in apex code but we are not getting any standard method to get it encrypted using EncodingUtil class.

WebService that we want to consume makes it compulsory to Bcrypt during authentication process.

NOTE: We dont want to any JS as code will be called from scheduled class.

 Also Crypt function of PHP produces the same result. So, any equivalent of Crypt in php or Bcrypt in java/javascript would work

Thanks!
I have to send outobund http request by using PATCH method, but salesforce httprequest.setMethod(), not support PATCH method, So please help me how can I achive this?
Hi All,

1 -Is there any limits governing for rest api callout while its transferring data to other service?
Like I have SF org and one is Heroku Web app. If I am sending request from Heroku to Sf so is there any limitation comes while sending data ?
2- If I am posting some data on SF from Heroku so is there any limitation hits like size of content etc.

Please let me know if anyone know this.

Thanks in advance
I have a requirement where I need to make the owner follow a record based on certain conditions. Now when I change the owner, the new owner should automatically follow the record. However the code I have written is making both the old and new owner follow the record. How to make the the old owner unfollow the record? 
Below is the piece of code I have written and I am calling this method from trigger on after insert and after update:

public static String doFollowRecord(List<Opportunity> opportunities, Map<Id, Opportunity> oldMap, Map<Id, Opportunity> newMap) {
        String errMsg;
        if(isInsert){
        for (Opportunity opp : opportunities) {
            if (opp.RecordTypeId == opportunityRecordTypeNameToIdMap.get(RENEWALRECORDTYPE.toLowerCase()) && opp.Managed_Opportunity__c ==True) {
                EntitySubscription follow = new EntitySubscription (
                                         parentId = opp.id,
                                         subscriberid =opp.ownerid);
                insert follow;
            }
                                                }
                                }  
        return errMsg;
    }


Need urgent help on this.
Hi Guys,
               Is there anyway that we can monitor the apex job queue and send an email alert when the jobs are not processed for more than 5 minutes.
We have observed that the future jobs are queued sometimes and take a long time to process.
It would be good if we can get an email alert in such scenarios.

Regards,
Sandy
Hello all,

I need to add a picklist field to the CommunitiesSelfReg VF page, but am getting the error below because I need to change it from inputext to inputfield, otherwise it won't show the drop-down menu.

"Could not resolve the entity from <apex:inputField> value binding '{!purchasedfrom}'.  <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable."

VF Page:

 
<apex:page id="communitiesSelfRegPage" showHeader="true" controller="CommunitiesSelfRegController" title="{!$Label.site.user_registration}">
     <apex:define name="body">  
      <center>
<apex:form id="theForm" forceSSL="true">
                    <apex:pageMessages id="error"/>
                    
                    
                    <apex:panelGrid columns="2" style="margin-top:1em;">
                      <apex:outputLabel style="font-weight:bold;color:red;" value="First Name" for="firstName"/>
                      <apex:inputText required="true" id="firstName" value="{!firstName}" label="First Name"/>
                      <apex:outputLabel style="font-weight:bold;color:red;" value="Last Name" for="lastName"/>
                      <apex:inputText required="true" id="lastName" value="{!lastName}" label="Last Name"/>
                      <apex:outputLabel style="font-weight:bold;color:red;" value="{!$Label.site.email}" for="email"/>
                      <apex:inputText required="true" id="email" value="{!email}" label="{!$Label.site.email}"/>
                      
                      <apex:outputLabel style="font-weight:bold;color:red;" value="Phone" for="phone"/>
                      <apex:inputText required="true" id="phone" value="{!phone}" label="Phone"/>
                      <apex:outputLabel value="Title" for="title"/>
                      <apex:inputText required="true" id="title" value="{!title}" label="Title"/>                      
                      <apex:outputLabel style="font-weight:bold;color:red;" value="Company" for="companyname"/>
                      <apex:inputText required="true" id="companyname" value="{!companyname}" label="Company"/>                      

                      <apex:outputLabel style="font-weight:bold;color:red;" value="Street" for="street"/>
                      <apex:inputText required="true" id="street" value="{!street}" label="Street"/>
                      <apex:outputLabel style="font-weight:bold;color:red;"  value="City" for="city"/>
                      <apex:inputText required="true" id="city" value="{!city}" label="City"/>
                      <apex:outputLabel style="font-weight:bold;color:red;"  value="Zip" for="postalcode"/>
                      <apex:inputText required="true" id="postalcode" value="{!postalcode}" label="Zip"/>
                      <apex:outputLabel style="font-weight:bold;color:red;"  value="Country" for="country"/>
                      <apex:inputText required="true" id="country" value="{!country}" label="Country"/>
                      <apex:outputLabel style="font-weight:bold;color:red;"  value="State" for="state"/>
                      <apex:inputText required="true" id="state" value="{!state}" label="State"/>
                      
                      <apex:outputLabel value="Product Owner" for="productowner"/>
                      <apex:inputText required="true" id="productowner" value="{!productowner}" label="Product Owner"/>
<!--                       <apex:outputLabel value="Purchased From" for="purchasedfrom"/> -->
<!--                       <apex:inputText required="true" id="purchasedfrom" value="{!purchasedfrom}" label="Purchased From"/> -->
                      <apex:outputLabel value="Serial Number" for="serialnumber"/>
                      <apex:inputText required="true" id="serialnumber" value="{!serialnumber}" label="Serial Number"/>
                      
                      <apex:inputfield value="{!u.Purchased_From__c}"/>  
                      
					  <apex:outputLabel value="{!$Label.site.community_nickname}" for="communityNickname"/>
                      <apex:inputText required="true" id="communityNickname" value="{!communityNickname}" label="{!$Label.site.community_nickname}"/>                      
                      <apex:outputLabel value="{!$Label.site.password}" for="password"/>
                      <apex:inputSecret id="password" value="{!password}"/>
                      <apex:outputLabel value="{!$Label.site.confirm_password}" for="confirmPassword"/>
                      <apex:inputSecret id="confirmPassword" value="{!confirmPassword}"/>
                      <apex:outputText value=""/>
                      <apex:commandButton action="{!registerUser}" value="{!$Label.site.submit}" id="submit"/>
                    </apex:panelGrid> 
                  <br/>
</apex:form>
     </center>
      <br/>
    </apex:define>

</apex:page>

Class:
 
/**
 * An apex page controller that supports self registration of users in communities that allow self registration
 */
public with sharing class CommunitiesSelfRegController {

  public String firstName {get; set;}
  public String lastName {get; set;}
  public String email {get; set;}
  public String phone {get; set;}
  public String title {get; set;}
  public String companyname {get; set;}
  public String street {get; set;}
  public String city {get; set;}
  public String postalcode {get; set;}
  public String country {get; set;}
  public String state {get; set;}
  public String productowner {get; set;}
  public String purchasedfrom {get; set;}
  public String serialnumber {get; set;}
  public String password {get; set {password = value == null ? value : value.trim(); } }
  public String confirmPassword {get; set { confirmPassword = value == null ? value : value.trim(); } }
  public String communityNickname {get; set { communityNickname = value == null ? value : value.trim(); } }
  
  public CommunitiesSelfRegController() {}
  
  private boolean isValidPassword() {
    return password == confirmPassword;
  }

  public PageReference registerUser() {
  
    // it's okay if password is null - we'll send the user a random password in that case
    if (!isValidPassword()) {
      System.debug(System.LoggingLevel.DEBUG, '## DEBUG: Password is invalid - returning null');
      ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, Label.site.passwords_dont_match);
      ApexPages.addMessage(msg);
      return null;
    }  

    
    String profileId = '00ej0000000jJMR'; // To be filled in by customer.
    
    String accountId = '001g000000QMTDX'; // To be filled in by customer.  

    // Set this to your main Communities Profile API Name
    String profileApiName = 'PowerCustomerSuccess';
    //String profileId = [SELECT Id FROM Profile WHERE UserType = :profileApiName LIMIT 1].Id;
    //List<Account> accounts = [SELECT Id FROM Account LIMIT 1];
    //System.assert(!accounts.isEmpty(), 'There must be at least one account in this environment!');
    //String accountId = accounts[0].Id;
    
    String userName = email;

    User u = new User();
    u.Username = userName;
    u.Email = email;
    u.Phone = phone;
    u.Title = title;
    u.Street = street;
    u.City = city;
    u.PostalCode = postalcode;
    u.Country = country;
    u.State = state;
    u.Product_Owner__c = productowner;
    u.Purchased_From__c = purchasedfrom;
    u.Serial_Number__c = serialnumber;
    u.CompanyName = companyname;
    u.FirstName = firstName;
    u.LastName = lastName;
    u.CommunityNickname = communityNickname;
    u.ProfileId = profileId;
    
    String userId = Site.createPortalUser(u, accountId, password);
   
    if (userId != null) { 
      if (password != null && password.length() > 1) {
        System.debug(System.LoggingLevel.DEBUG, '## DEBUG: User creation successful and password ok - returning site.login');
        return Site.login(userName, password, null);
      }
      else {
        System.debug(System.LoggingLevel.DEBUG, '## DEBUG: User creation successful but password not ok - redirecting to self reg confirmation');
        PageReference page = System.Page.CommunitiesSelfRegConfirm;
        page.setRedirect(true);
        return page;
      }
    }
    System.debug(System.LoggingLevel.DEBUG, '## DEBUG: User creation not successful - returning null');
    return null;
  }
}


Thanks!!!

Ronaldo.
public List<CustomClass> list = [Select AColumn__c, BColumn__c
                                                  From CustomClass
                                                  WHERE UserId = :UserInfo.getUserId() 
                                                         and BColumn__c =:'TEST'];

Also tried
BColumn__c like 'TEST%'

BColumn__c is a Picklist which can have value TEST, TEST01, TEST03,etc


I am not able to make a correct string comparision

  • February 24, 2015
  • Like
  • 0
Hello,
I have a component that is used by multiple pages, displaying different data (in the same layout) based on the page it is loaded in.
Both the Page and the Component use the same controller, the logic of the component controler is embedded in the page controller logic.
Is there a way for the page to pass its controller name as an attribute to the compoent? It works fine for language but it seems that controller value must be only string between " ".  Any workaround?
Thanks in advance for your help and any idea. Otherwise, I have to create one component to fit each page, just different in their controller name. What I would like is something like:
<apex:page controller=" ControlerForThisPage" >
<c:componentName controller= "ControlerForThisPage" language= "en_US" />     <!--assigning controller value on component -->
<…
</apex :page>
Component :
<apex:component controller= "{ !controller}" language="{ !language}" >  <!--  How to pass ControlerForThisPage here? -->
<apex:attribute name=controller type="string" ..
<apex:attribute name=language  type="strng" ..
<..
</apex:component>
 
Hi there,

We have a Change Set that we want to validate on Production. Will Validating the Change Set prevent the Users from logging in and creating or updating/deleting records while the Validation is running?

Thanks,
Sandeep
Dear all, below is my code which automatically send email notificaitons when a new Event is created. If opportunity is not tagged to Event, I`m getting a System.NullpointerException. Could you please help in understanding what I`m doing wrong? I`m new to Apex 

Apex trigger NotifyOnSiteVist2 caused an unexpected exception, contact your administrator: Visitnotify: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.Visitnotify: line 29, column 1

 
Trigger Visitnotify on Event (after insert){
        
    List<Messaging.SingleEmailMessage> newEmails = new List<Messaging.SingleEmailMessage>();
    List<Id> whatIds = new List<Id>();
    List<Id> createdByIds = new List<Id>();
    for(Event e :Trigger.new)
    {
        createdByIds.add(E.CreatedByID);
        whatIds.add(E.whatId);
    }
    Map<Id, User> users = new Map<Id, User>([SELECT Id, Name from User WHERE Id in :createdByIds]);
    Map<Id, Opportunity> opportunities = new Map<Id, Opportunity>([SELECT Name, Account.Name from Opportunity WHERE Id in :whatIds]);
    for(Event e :Trigger.new){
    
    if(e.whatid != NULL){ 
            String fullTaskURL;
            String Facility;
            Datetime startDate;
            Datetime endDate;
            String Purpose;

            
            // Query to populate CreatedBy name in html template
            Id createdByID = E.CreatedByID;
            String createdByName = users.get(createdByID).Name;
                   
            // Query to populate Opportunity name in html template
            String oppID = E.whatId;  
            String oppName = opportunities.get(oppID).Name;
                                 
        if(E.Site_Visit__C ){
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                
            mail.setSubject(' Alert: A New Visit Record is Created');
            mail.setSaveAsActivity(false);
            mail.setTargetObjectId('00580000005LedR'); 
                                     
            fullTaskURL = URL.getSalesforceBaseUrl().toExternalForm() + '/' + E.Id;
            Facility = E.Facility__c;
            startDate = E.StartDateTime;
            endDate = E.EndDateTime;
            Purpose = E.Purpose_of_Visit__c;
                
   
            //Generate email template
                String emailBody;
                emailBody = '<html><body>Hi ,<br> <br> A New Site Visit Record has been created: <a href="' + fullTaskURL + '">' + E.Id + '</a><br></body></html>' + '<br> Sales VP: '+ createdByName + '<br> Opportunity/Account Name: '+ oppName + '<br> <br> Site/Facility: ' + Facility+ '<br> Purpose of Visit: ' + Purpose +  '<br> Start Date/Time: ' + StartDate +  '<br> End Date/Time: ' +endDate +  '<br> <br> Thank you <br> <br> Salesforce Admin' ;
                mail.setHtmlBody(emailBody );

            newEmails.add(mail);
        }
    }

    messaging.sendEmail(newEmails);
} }

 
I want to add if condition for below Opportunity button.  where Opportunity recordType is  'Flexy' then i have to  populate Task picklist field values as 'Flex'...if Opportunity recordType is 'Matue' then I have to populate Task picklist field value as 'Matue'. But when i added below If condition is getting syntax error.


/00T/e?who_id={!Contact.Id}&RecordType={!Task.RecordTypeId}&tsk6={!Opportunity.Description}&tsk1={!User.Name}&tsk13 = 'Normal'&00N40000002dXt2 = {!Opportunity.Product_Interest__c}&tsk3= {!Opportunity.Name}&tsk3_lkid ={!Opportunity.Id}&tsk4={!TODAY()}&{!IF(Opportunity.RecordTypeId=='012400000009mCC' ,  ISPICKVAL(!Task.Product_Type__c, 'VA') , NULL)}&tsk5={!Opportunity.Name}&retURL=%2F/006/o
I added the Custom Button to the 'Contact Layout' but still it says - Challenge not yet complete... here's what's wrong: 
The 'Google Link' custom button was not found. 
I am confused as to why this is happening. I am attaching screenshots and would appreciate any suggestions, thank you.
User-added image
User-added image
User-added image
When I'm adding script files to a lightning component i'm getting an error as 'script tags only allowed in templates: Source'. Is there another way to add script links to the lightning application?
Hi,
I need that my column header value in a pagebloack table in vf page should be fixed while scrolling and viewing data.
How to do this?

Thanks in Advance!
We are getting following error while creating a task in Salesforce.
Error msg: Too many retries of batch save in the presence of Apex triggers with failures: when triggers are present partial save requires that some subset of rows save without any errors in order to avoid inconsistent side effects from those triggers. Number of retries: 2 
We are getting this error on calling SforceService.create() function.

Please let me know the solution for this.

@isTest(SeeAllData=True)
public class TestStatAndStop {
    public static testmethod void MyMothod()
    {
        for (integer i =1; i<=90;i++)
            Contact b1 = [select id from contact limit 1];
        Test.startTest();
        for (integer i1 =1; i1<=99;i1++)
        {
            Account b = [select id from account limit 1];
        }  
        Test.stopTest();
}
}
Hi All,

I am looking for soql which could fetch me all the license used for all inactive and active users in one shot. similar to displaying company license information in native SFDC environment.

I am working on displaying the license information on VF such that i can have my own custom activation and deactivation of users in organization.

Any light on this is greatly appreciated.
Hi,
I am trying to develop a visual force page in which the list of records should be displayed on the click of the object name.
The same functionality is working fine with the check box,but i want it to be done with links.
This is my code which is displaying the list of records when the check box is checked.

<apex:page controller="multirecords" >
<apex:form >
<apex:messages />
<apex:pageBlock id="theBlock">                                                    
<apex:inputCheckbox value="{!Check}" required="false">
<apex:actionSupport event="onclick" rerender="theBlock"/>
</apex:inputCheckbox>
         
<apex:outputLabel value="View Job Application"  style="font-weight:bold;"></apex:outputLabel>&nbsp;<br/>
<apex:inputCheckbox value="{!Check1}" required="false">
<apex:actionSupport event="onclick" rerender="theBlock"/>
</apex:inputCheckbox>
<apex:outputLabel value="View Positions"  style="font-weight:bold;"></apex:outputLabel>&nbsp;<br/>
<!--  <apex:commandLink value="Positions"  action="{!display}" id="position" rendered="{!inputmode}">
<apex:actionSupport event="onclick" rerender="theBlock"/>
</apex:commandLink>-->
           
<apex:pageBlock title="Job Application" rendered="{!(Check == true)}">          
<apex:pageblockTable value="{!ja}" var="a">
<apex:column value="{!a.Name}"/>
</apex:pageblockTable><br/>
</apex:pageBlock>                                
<apex:pageBlock title="Position" rendered="{!(Check1 == true)}">                
<apex:pageblockTable value="{!pos}" var="p">
<apex:column value="{!p.Name}"/>
</apex:pageblockTable>
</apex:pageBlock>     
</apex:pageBlock>    
</apex:form>
</apex:page>

---Controller--
public class multirecords {

      
    public List<Job_Application__c> ja {get; set;}
    public List<Position__c> pos {get; set;}
    public List<Review__c> rev {get; set;}
    public boolean Check{get;set;}
    public boolean Check1{get;set;}
    public boolean Check2{get;set;}
    public multirecords()
    {
       
       ja = [SELECT Name FROM Job_Application__c];
       pos = [SELECT Name FROM Position__c];
    }
          

}