• Sanchivan Sivadasan
  • NEWBIE
  • 15 Points
  • Member since 2011
  • CEO / Salesforce Consultant
  • TapMyBrain Inc.

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 35
    Questions
  • 39
    Replies
Hi All, 
 
I am writing a trigger on ContentVersion in a Scratch Org and I have the below code working in a developer org, but it won't save in a Scratch org and I am getting the error "Variable does not exist: ContentDocumentId". The Trigger code is as follows:
trigger ContentVersionTrigger on ContentVersion (after insert) {
    Set<Id> contentDocumentIdSet = new Set<Id>();

    for(ContentVersion cv : Trigger.New) {
        contentDocumentIdSet.add(cv.ContentDocumentId);
    }
}
Also, if I comment out the code contentDocumentIdSet.add(cv.ContentDocumentId);

I get the following error:

"Invalid loop variable type expected ContentVersion was ContentVersion"

Does anyone know why?
Hi there,

I have an object called Options. This object has a field called Region and this field needs to default to the user's region. The User Object has a picklist value called region. We want to default this value to the user's region and then give them ability to change it if they want to if needed. We have lightning enabled.
Hi there,

I have an object called Options. This object has a field called Region and this field needs to default to the user's region. The User Object has a picklist value called region. We want to default this value to the user's region and then give them ability to change it if they want to if needed. We have lightning enabled. I want to make this work for classic and lightning if possible. I am trying to override the New Button for the Option Object and pre-populate the fields that I need to pre-populate and then redirect the user to the object which we need to redirect them to. How do I go about doing this? 

This is what I have done so far and have not worked:

I created a Visualforce page called OptionNewBtnOverride
 
<apex:page standardController="Option__c" extensions="OptionExtension" action="{!pageDirect}">
    <script>
    	window.onLoad = function() {
            var defaultValues = {
                               'Region__c' : {!region}
                             };
        	sforce.one.createRecord('Option__c', null, defaultValues);   
        }
    </script>
</apex:page>
I also have an extension class called OptionExtension as follows:
public class OptionExtension {
    public String region {get; set;}
    public OptionExtension(ApexPages.StandardController controller) {        
    }
    
    public void pageDirect() {
        string region = [Select Region__c From User Where Id = :UserInfo.getUserId()][0].Region__c;
    }
}

For the Option Object's New Button override, I have selected, visualforce for classic and for lightning and mobile I have selected use salesforce classic override. Can someone tell me what I am doing wrong here? Thanks
How can you have multiple URL's mapped to the same URL? For an example, in the case of the contacts related to a customer, we should be able to request these via a GET request to:
/contacts/?accountId=<accountId>
/accounts/<accountId>/contacts

Is this possible? How would you do this? Thanks.
What is the best approach to integrate Visualforce and third party app. I need to be able to have a Visualforce page display this third part app as part of a section and pass parameter to it and once the user is done interacting with that app the data from third part app needs to be passed to the Visualforce page and a method needs to be call to process that completion. 

How do I go about doing this and what's the best approach?

I know Salesforce has something called Force.com canvas, but not sure if Canvas allows communication between the Visualforce page and the Canvas app and Canvas app to Visualforce page. 

Thanks.

Sanch.
Hi there,

I have a JSON that is being returned from an HTTP Callout and for which I am using an Apex Class to deserialize. Everything is working as expected when I test it through the developer console. But when I write test coverage, the class for which I am deserializing to is showing up as not covered by the test class.

Does the JSON.deserialize cover the class that it's deserializing to or does it not? Thanks.

Sanch.
 
Hi there, 

Is the OR Clause not supported in SOQL for the DataCloudContact object from Data.com? 

When I run this in developer console, I am get an exception stating 'OR is not supported!'. What options do I have? 
 
SELECT Id, FirstName, LastName, CompanyName, Email FROM DataCloudContact
WHERE ((FirstName LIKE 'test' AND LastName LIKE 'test' AND CompanyName LIKE 'test Inc.') OR Email Like 'test@test.com')

 
Hi there,

I have an Apex Rest Webservice that I need to call but without oAuth. I want to use my username and password to authenticate. Is this possible? If yes, how can I do this? Assume that I will be calling this from either Java or C#. Thanks.

SS.

 
Hi there,

I need to create a webservice that return's all accounts plus some other data from other objects through an Apex Webservice. I also have a field on the account object that has the URL for an image that is attached on the Notes and Attachments section of the account record.  I need to return the image as part of the webservice call for each account. Is this possible and how can I do this?  The system that is calling the webservice is not within Salesforce.

Also, is there a limit on how many account records that we can return in one webservice all? 

Thanks.

Sanch
Hi there,

I have a custom Visualforce page which is all html with styling and format to this site: (http://www.salesforce.com/products/30daytrial/pe-getting-started.jsp). This seems to affect the header and sidebar of the salesforce when I go to that page. Why is this happening? What can I do to fix this? Thanks.

S.S.
Hi there,

We have a workflow that leverages a Text Email Template type. The workflow and the emails are getting triggered and being sent. But for the past few days what is happening is there is '<html>' tag that is added at the top of the email that is being sent. Is anyone else having the same issue? Thanks in advance.

Sanchivan S.
Hi all,

I currently have a Salesforce Administrator available. Please let me know if you are looking for a Salesforce Admin. Thank you.

Sanchivan Sivadasan
Sanchivan@TapMyBrainInc.com
416-275-6647
Hi All,

I have an object called ShiftConfig with the following:
StartTime
EndTime
Enabled__c
Sunday__c
Monday__c
Tuesday__c
Wednesday__c
Thursday__c
Friday__c
Saturday__c

So for each weekday we can have multiple shifts. For an example, we can have the following:

Tuesday:
            StartTime   EndTime
Shift1: 0600         -   1200
Shift2: 1200         -   1800
Shift3: 1800         -   0600

We need a validation so the times do not overlap. So we need to prevent something like this:

Tuesday:
            StartTime   EndTime
Shift1: 0600         -   1200
Shift2: 1100         -   1800
Shift3: 1500         -   0600

How can I do this in a trigger?

Thanks.

Sanch.
Hi All,

I have a workflow that sends out email alerts. This workflow is on the Lead Object.

In the Receipients section the Email Field: Email as the receipient.

In the Additional Emails section I have additional two email addresses that get's cc'd.

In the From Email Address section I have selected an Organization-Wide Email Address that I have configured. The Organization-Wide is in the status of verified. 

The email that is being sent to the Email Field has the proper from email address.

For the Additional Emails, it is showing up as noreply@salesforce.com. 

What is it that I am missing so it shows the proper from email address for the Additional Emails as well? 

Thanks.

Sanch 

Hi there,

 

Currently there is no actions in the Approval configuration that I can do to send an email alert when a user reassign the approval step to someone else.  Is there anyone who was able to archieve this by any other means? Thanks.

 

Sanch.

Hi there,

 

I am getting the following ERROR:

Exception: System.JSONException: Illegal value for primitive

When I try to deserialize the HTTP response from Jive to an object.

 

JivePersonObject personRecord = (JivePersonObject) System.JSON.deserialize(jiveResponse, JivePersonObject.class);

 

I have validated the JSON string at http://jsonlint.com/ and it is valid. 

 

This is not happening for all the response. It is happening for some response and some of them don't have the issue.

 

I was wondering if anyone have come across this issue before. Not sure what I am doing wrong here. Thanks.

 

Sanch

Hi there,

I have a requirement where I need to generate pdfs for multiple clients where the Data is being pulled from multiple objects. There will also be paging involved as well.

The Object Structure is:

- Tender
          - Opportunity (Maximum 3 opportunities)
                    - Products (N number of productions) - Need paging
          - Customers (Junction Object between Account and Tender)

In the above case, we have Opportunities record types A, B, C. We can have one opportunity for each record type under a particular Tender. So in total we can have a maximum of 3 Opportunities for each tender record.

In the Customers related list, I will have three button's:A Quote, B Quote, C Quote. When the user clicks a button, we need to generate PDFs with quote for all the Customers and attach to Notes and Attachment. So let's say the quote letter for Opportunity record type A is 3 pages for each customer and let's assume we have 3 customers. We will have 3 PDFs.

I want to know the best approach to this problem. Can I leverage visualforce Email template for this? Do I just use visualforce page and render it as pdf? How do I approach this? 

 

Thanks.

Hi there,

 

I tried log in as a Customer Portal User and run a report, but I get zero results. I go to the record tab and I am able to see the record as the user. So the user does have access to the record, but I can't see the record on the reports. Does anyone have this issue?

 

I have already checked the following:

1. The report folder permission is set to This folder is accessible by all users, including portal users 

2. The custom object is enabled for Reports

3. The object that we are reporting is a Child of an Object which is a Child of Account. I tried creating custom AccountShare record for the Customer Portal user even though the user should automatically have it, but that didn't work either.

 

Thanks.

 

Sanch S. 

Hi there,

 

In the testmethod, I am trying to disable a Customer Portal User which I created within the testmethod by doing the following:

 

// Disable the peteSamprass portal use
peteSamprassUser.IsPortalEnabled = False;
peteSamprassUser.IsActive = False;
update peteSamprassUser;
	        
peteSamprassUser = [SELECT Id, AccountId, ContactId, IsActive, IsPortalEnabled FROM User WHERE Id =:peteSamprassUser.Id];
System.assertEquals(peteSamprassUser.IsPortalEnabled, False) System.assertEquals(peteSamprassUser.IsActive, False);

 For some reason the IsPortalEnabled reverts back to True even though I am clearly updating the field. As a result the Assert Statement for IsPortalEnabled fails. I also noticed that IsActive is propery set to False, so we don't have an issue with IsActive field.

 

Then I also tried disabling the Account record for Customer Portal as follows:

 

account101.IsCustomerPortal = False;
update account101;
	        
account101 = [SELECT Id, Name, IsCustomerPortal FROM Account WHERE Id =:account101.Id];
System.assertEquals(account101.IsCustomerPortal, False);

 This statement also fails.  Please let me know what I am doing wrong. Thanks.

 

Sanch S.

Hi there,

 

I have the following scenario:

 

1. Retail Cluster (Master): The company that owns one or more Retail Stations 

2. Retail Stations (Detail): The Retail Station under the Retail Cluster  

 

Required Security Funtionality:

1. If the Retail Cluster Owner log in through the Customer Portal, they should see all the Retail Stations that they own.

2. If the Retail Station Manager log in, they should ONLY see details about the Staion that they are the manager for.

 

Current approach:

 

Assume we have a Retail Cluster 100 and we have Retail Stations called 100.1 and 100.2. 

 

We made Retail Cluster a child of Account.

 

We created an Account Hierarchy of:

 

100

    - 100.1

    - 100.2

 

We also added the

    - Retail Cluster Owner as a contact under Account 100.

    - Retail Station Managers as a contact under 100.1 and 100.2

We enabled the contact records for Customer portal.

 

This works when the Contact from 100.1 and 100.2 log in. They only see their records. But when the contact from 100 log in they do not see any records. Also, please note the Account object is set as Private.

 

The question that I have is why is this not taking the Account Hierarchy and assingining the permission accordingly? What is the best approach to over come this. I want to try to ignore creating custom sharing records through Apex. Please let me know if you guys have any suggestions. Thank you.

 

Sanch S.

Hi All, 
 
I am writing a trigger on ContentVersion in a Scratch Org and I have the below code working in a developer org, but it won't save in a Scratch org and I am getting the error "Variable does not exist: ContentDocumentId". The Trigger code is as follows:
trigger ContentVersionTrigger on ContentVersion (after insert) {
    Set<Id> contentDocumentIdSet = new Set<Id>();

    for(ContentVersion cv : Trigger.New) {
        contentDocumentIdSet.add(cv.ContentDocumentId);
    }
}
Also, if I comment out the code contentDocumentIdSet.add(cv.ContentDocumentId);

I get the following error:

"Invalid loop variable type expected ContentVersion was ContentVersion"

Does anyone know why?
Hi there,

I have an object called Options. This object has a field called Region and this field needs to default to the user's region. The User Object has a picklist value called region. We want to default this value to the user's region and then give them ability to change it if they want to if needed. We have lightning enabled. I want to make this work for classic and lightning if possible. I am trying to override the New Button for the Option Object and pre-populate the fields that I need to pre-populate and then redirect the user to the object which we need to redirect them to. How do I go about doing this? 

This is what I have done so far and have not worked:

I created a Visualforce page called OptionNewBtnOverride
 
<apex:page standardController="Option__c" extensions="OptionExtension" action="{!pageDirect}">
    <script>
    	window.onLoad = function() {
            var defaultValues = {
                               'Region__c' : {!region}
                             };
        	sforce.one.createRecord('Option__c', null, defaultValues);   
        }
    </script>
</apex:page>
I also have an extension class called OptionExtension as follows:
public class OptionExtension {
    public String region {get; set;}
    public OptionExtension(ApexPages.StandardController controller) {        
    }
    
    public void pageDirect() {
        string region = [Select Region__c From User Where Id = :UserInfo.getUserId()][0].Region__c;
    }
}

For the Option Object's New Button override, I have selected, visualforce for classic and for lightning and mobile I have selected use salesforce classic override. Can someone tell me what I am doing wrong here? Thanks
How can you have multiple URL's mapped to the same URL? For an example, in the case of the contacts related to a customer, we should be able to request these via a GET request to:
/contacts/?accountId=<accountId>
/accounts/<accountId>/contacts

Is this possible? How would you do this? Thanks.
Hi All,

I have written a Trigger to update a custom field (Account__c) on ContentVersion.
The Trigger does not have any error but when I try to updload a file in an Account I got an error message "Can't updload (file name)".
Something wrong with the Trigger but I can't figure it why. 
trigger UpdateAccountonFile on ContentVersion (after insert) {

    Set<Id> docIds = new Set<Id>();
    
    for(ContentVersion cv : trigger.new){  
       
      if(cv.ContentDocumentId != null)
            {
                docIds.add(cv.ContentDocumentId);
        }  
    }     
  ContentDocumentLink c = [SELECT ContentDocument.Id, ContentDocument.Title, Id, LinkedEntityId FROM ContentDocumentLink WHERE ContentDocument.Id In:docIds ];   
    
   List<Account> accList = [SELECT Id, name FROM Account WHERE Id =:c.LinkedEntityId ];            
    
    for(ContentVersion cv : trigger.new){      
        
        if(accList.size() > 0){
            for(Account a : accList){
                cv.Account__c = a.Id;
            }
        }
        else{
            cv.Account__c = null; 
        }            
    }
}

Thanks in advance for your help.
Sylvie 
 
Hi there,

I have a JSON that is being returned from an HTTP Callout and for which I am using an Apex Class to deserialize. Everything is working as expected when I test it through the developer console. But when I write test coverage, the class for which I am deserializing to is showing up as not covered by the test class.

Does the JSON.deserialize cover the class that it's deserializing to or does it not? Thanks.

Sanch.
 
Workflow Action Failed to Trigger Flow
The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 30128000000RUrR. Flow error messages: &lt;b&gt;An unhandled fault has occurred in this flow&lt;/b&gt;&lt;br&gt;An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information. Contact your administrator for help.

Explaination : Even after i deleted the trigger, i am getting this while updating the account fields.
 
Hi there,

I have an Apex Rest Webservice that I need to call but without oAuth. I want to use my username and password to authenticate. Is this possible? If yes, how can I do this? Assume that I will be calling this from either Java or C#. Thanks.

SS.

 
Hi there,

We have a workflow that leverages a Text Email Template type. The workflow and the emails are getting triggered and being sent. But for the past few days what is happening is there is '<html>' tag that is added at the top of the email that is being sent. Is anyone else having the same issue? Thanks in advance.

Sanchivan S.
I have a trigger on a Lead that verifies if the lead has been converted and does some actions if some criteria is met.
The code seems to work fine on the application but my test class fails when I programatically convert a Lead.

The error seems to be a validation rule that fails.
This validation rule uses information from the $ objects provided:
$Setup.ypg_switches__c.data_Lead__c
Where ypg_switches is a hierarchical custom setting having data_Lead as a checkbox (true/false)
This "Error Condition Formula" always fails on my test method no matter what the value of the custom setting is with the following error:
16:32:39.116 (6116300765)|FATAL_ERROR|System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Validation Formula "AC" Invalid (null): []
Usually we expect to receive the error message.

I also tested another Error Condition Formula:
$User.data_AllOrAccount__c
This is a calculated field on the user object that return true or false but i'm experiencing the same behaviour... failure nomatter what's the value.

My question are...
Is it possible that those $objects are not available when in test mode?
If not available, how to test something like this?  I don't want to disable any validation rules just to test code!
If available, what am I doing wrong?

Here's the whole test class:
/**************************************************************************
 * Tests the MigrateAssociatedAssignmentRequests fonction
 **************************************************************************/
@isTest static void MigrateAssociatedAssignmentRequestsTest() {
	Integer nbObjectsToTest = 1;
	
	//preparing test (creates the custom setting if not available)
	ypg_Switches sws = new ypg_Switches(false);
	sws.dataAllSwitch = true;
	sws.dataLeadSwitch = true;
	sws.dataLoadSwitch = false;
	sws.saveToSF();
	
	String ownerToUse = retrieveUserId('John Doe');
	String ARType = retreiveRType('Assignment_Request');
	
	Lead[] leads = generateTestLeads(nbObjectsToTest, '514');
	
	//create AR
	Case c = new Case(
		RecordTypeId = ARType,
		Type = AR_TYPE_GENERAL,
		Status = AR_STATUS_INPROGRESS,
		Requested_By__c = ownerToUse
	);
	
	insert c;
	
	list<Assignment_Request_Item__c> aris = new list<Assignment_Request_Item__c>();
	
	//create AR Item
	for(Lead l: leads) {
		Assignment_Request_Item__c ari = new Assignment_Request_Item__c(
			Lead__c = l.Id,
			Case__c = c.Id,
			Assignee__c = ownerToUse
		);
		
		aris.add(ari);
	}
	
	insert aris;
	
	//preparing Lead convert
	LeadStatus ls = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
	list<Database.LeadConvert> converts = new list<Database.LeadConvert>();
	
	for(Assignment_Request_Item__c ari: aris) {
		Database.LeadConvert lc = new Database.LeadConvert();
		
		lc.setLeadId(ari.Lead__c);
		lc.setConvertedStatus(ls.MasterLabel);
		
		converts.add(lc);
	}
	
	Test.startTest();
	
	//convert leads
	Database.LeadConvertResult[] lcrs = Database.convertLead(converts);
	
	Test.stopTest();
	
	//asserting outcome
	system.assert(sws.dataAllSwitch);
	system.assert(sws.dataLeadSwitch);
	
	map<Id,Id> LeadToAcntMap = new map<Id,Id>();
	
	for(Database.LeadConvertResult lcr: lcrs) {
		system.assert(lcr.isSuccess());
		LeadToAcntMap.put(lcr.getLeadId(), lcr.getAccountId());
	}
	
	map<Id, Assignment_Request_Item__c> ariMap = new map<Id, Assignment_Request_Item__c>(aris);
	Assignment_Request_Item__c[] arisUpd = [SELECT Id, Case__c, Account__c, Lead__c FROM Assignment_Request_Item__c WHERE Id IN :ariMap.keySet()];
	
	for(Assignment_Request_Item__c ari: arisUpd) {
		system.assertEquals(null, ari.Lead__c);
		system.assertEquals(LeadToAcntMap.get(ariMap.get(ari.Id).Lead__c), ari.Account__c);
	}
}
Thanks for your help!



Hi All,

I have an object called ShiftConfig with the following:
StartTime
EndTime
Enabled__c
Sunday__c
Monday__c
Tuesday__c
Wednesday__c
Thursday__c
Friday__c
Saturday__c

So for each weekday we can have multiple shifts. For an example, we can have the following:

Tuesday:
            StartTime   EndTime
Shift1: 0600         -   1200
Shift2: 1200         -   1800
Shift3: 1800         -   0600

We need a validation so the times do not overlap. So we need to prevent something like this:

Tuesday:
            StartTime   EndTime
Shift1: 0600         -   1200
Shift2: 1100         -   1800
Shift3: 1500         -   0600

How can I do this in a trigger?

Thanks.

Sanch.

Hi there,

 

Currently there is no actions in the Approval configuration that I can do to send an email alert when a user reassign the approval step to someone else.  Is there anyone who was able to archieve this by any other means? Thanks.

 

Sanch.

Needed: Trigger on contact that will populate 3 phone numbers on the account object and the respective names (from guardian contact record).

 

Conditions: When a contact is edited or added, if the Phone Status has a working number then it should populate the account object with the working number. Will pull all the other contact objects with the same account ID and populate the account with the first 3 instances of a working phone number

 

Additonal InfoAccounts are being used to hold Household members. Contacts are being used for record type Student and Guardian.

Hi there,

 

In the testmethod, I am trying to disable a Customer Portal User which I created within the testmethod by doing the following:

 

// Disable the peteSamprass portal use
peteSamprassUser.IsPortalEnabled = False;
peteSamprassUser.IsActive = False;
update peteSamprassUser;
	        
peteSamprassUser = [SELECT Id, AccountId, ContactId, IsActive, IsPortalEnabled FROM User WHERE Id =:peteSamprassUser.Id];
System.assertEquals(peteSamprassUser.IsPortalEnabled, False) System.assertEquals(peteSamprassUser.IsActive, False);

 For some reason the IsPortalEnabled reverts back to True even though I am clearly updating the field. As a result the Assert Statement for IsPortalEnabled fails. I also noticed that IsActive is propery set to False, so we don't have an issue with IsActive field.

 

Then I also tried disabling the Account record for Customer Portal as follows:

 

account101.IsCustomerPortal = False;
update account101;
	        
account101 = [SELECT Id, Name, IsCustomerPortal FROM Account WHERE Id =:account101.Id];
System.assertEquals(account101.IsCustomerPortal, False);

 This statement also fails.  Please let me know what I am doing wrong. Thanks.

 

Sanch S.

Hello Gurus,

 

I have a VisualForce page that is calling a Custom StandardSetController with Pagination. I go to page #2 and update a record. After I hit save, I am directed back to first page although {!CurrentPage} displays Page #2. How can I stay on the current record/Page after I hit save?

Here is the relevant code:

 

Controller code:

public with sharing class SMADummy {
    
public ApexPages.StandardSetController setCon {
    get {
        if (setCon== null){
            system.debug('Calling locator');
        setCon=new ApexPages.StandardSetController(Database.getQueryLocator(
                            [Select s.Name, Activity_Start_Date__c,Activity_End_Date__c From Dummy__c s order by name limit 30]));
                 
                
               
            }
            return setCon;
        }
        set;
    }
   public List<Smart_Marketing_Activity__c> getActivities() {
     
         return (List<Smart_Marketing_Activity__c>) setCon.getRecords();
 }

 

VF Code:

<apex:page controller="SMADummy">

<apex:form>

<apex:pageBlock>

    <apex:pageBlockButtons >
            
                <apex:CommandButton value="Save" action="{!save}" />
              
              </apex:pageBlockButtons>
          

  <apex:commandLink action="{!setCon.previous}" immediate="true" >Previous</apex:commandlink>
    <apex:commandLink action="{!setCon.next}" immediate="true">Next</apex:commandlink>
     <apex:pageBlockTable value="{!Activities}" var="SMA" >

 

 <apex:column >
               <apex:facet name="header">Activity Start Date</apex:facet>
               <apex:inputField value="{!SMA.Activity_Start_Date__c}" />
            </apex:column>

....

....

 </apex:pageBlockTable>
      
     </apex:pageBlock>
  </apex:form>

</apex:page>

We need a freelance SF developer that can develop and implement our lead to quote process. Travel Industry experience is a plus. We have existing data schema and workflow mapping. etc. Developer must be proficient in Force.com pages, web to lead Apex, Visual Force, IDE, migration tools, Web Services, third party API Integration. This is the first phase of our project. We are looking to develop an ongoing relationship with a freelance developer.
  • October 20, 2010
  • Like
  • 0

We are building an integration that requires us to send a time value that is within 30 seconds of the NIST standard time.  Does anyone know if the Salesforce server timestamp is synced to NIST?