• Grazitti Team
  • SMARTIE
  • 1875 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
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

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.