-
ChatterFeed
-
0Best Answers
-
1Likes Received
-
0Likes Given
-
12Questions
-
16Replies
How to share a file/document to non-salesforce users(user outside the org like legal team,customers)
Hi Experts,
I am looking for an advise/suggestion/guide on one of my requirement for which I haven't found a reliable solution yet
I am trying to implememt a functionality where I can share the files/documents on Salesforce to non-salesforce users(users outside my company) so that they can access the files outside.
I just wanted to understand if I can do this for non salesforce users? If yes what is the best way can we do this one?
Any help will be greatly appreciated
Many thanks in advance
Thanks & Regards,
Harjeet
I am looking for an advise/suggestion/guide on one of my requirement for which I haven't found a reliable solution yet
I am trying to implememt a functionality where I can share the files/documents on Salesforce to non-salesforce users(users outside my company) so that they can access the files outside.
I just wanted to understand if I can do this for non salesforce users? If yes what is the best way can we do this one?
Any help will be greatly appreciated
Many thanks in advance
Thanks & Regards,
Harjeet
- Harjeet Singh 28
- March 10, 2020
- Like
- 0
Share Salesforce Documents with External Users(Non-Salesforce Users)
Hi All,
I am trying to implememt a functionality where I can share the files on Salesforce to non-salesforce users(users outside my company) so that they can access the files outside.
I just wanted to understand if I can do this for non salesforce users? If yes what is the best way can we do this one?
Any help will be greatly appreciated
Many thanks in advance
Thanks & Regards,
Harjeet
I am trying to implememt a functionality where I can share the files on Salesforce to non-salesforce users(users outside my company) so that they can access the files outside.
I just wanted to understand if I can do this for non salesforce users? If yes what is the best way can we do this one?
Any help will be greatly appreciated
Many thanks in advance
Thanks & Regards,
Harjeet
- Harjeet Singh 28
- March 10, 2020
- Like
- 0
System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: [] test class
Hi All,
I have been stuck in test class and not getting a way to solve the issue.Upon running the test class I am getting error :System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []
Below is the CONTROLLER snippets:
Below is my test clas:
Kindly help
Many thanks in advance
I have been stuck in test class and not getting a way to solve the issue.Upon running the test class I am getting error :System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []
Below is the CONTROLLER snippets:
public class SurveyForDriverController{ //class variables public Driver_Survey__c survey{get;set;} public String newSurveyList {get;set;} public String newSurveyListSecond {get;set;} public String newSurveyListThird {get;set;} public String newSurveyListFourth {get;set;} public String newSurveyListFifth {get;set;} public SurveyForDriverController(ApexPages.StandardController controller){ system.debug('message3>>****'+ApexPages.currentPage().getParameters().get('recordID') ); if (ApexPages.currentPage().getParameters().get('recordID') !=null) survey = [SELECT Id, Name__c, Mobile__c, Email__c, from Driver_Survey__c where id = :ApexPages.currentPage().getParameters().get('recordID') ]; else survey=new Grab_Driver_Survey__c(); } public PageReference doFullSave(){ survey.Customer_Experience__c=newSurveyList; insert survey; PageReference pageRef = new PageReference('/'+survey.Id); pageRef.setRedirect(true); return pageRef; } public PageReference saveRecord( ) { survey.Customer_Experience__c=newSurveyList; update survey; return Page.DriverSurveyThankyouVF; } public void doCancel(){ PageReference pageRef = new PageReference('/'); pageRef.setRedirect(true); } }
Below is my test clas:
@isTest public class TestSurveyForDriverController { static testMethod void testForSalesforceUsers () { Profile p = [SELECT Id FROM Profile WHERE Name='Standard User']; Driver_Survey__c driverSurvey=new Driver_Survey__c(); ApexPages.StandardController ctlr = new ApexPages.StandardController(driverSurvey); SurveyForDriverController grabController=new SurveyForDriverController(ctlr); Test.startTest(); grabController.survey.Customer_Experience__c='6'; grabController.survey.Email__c='test@test.com'; grabController.survey.Expected_Earnings_Weekly__c=10000; grabController.survey.Name='testuser1'; grabController.survey.Name__c='testuser1'; grabController.doFullSave(); grabController.doCancel(); Test.stopTest(); } static testMethod void testForExternalUsers () { Profile p = [SELECT Id FROM Profile WHERE Name='Transport Questionnaire Profile']; Driver_Survey__c driverSurvey=new Driver_Survey__c(); ApexPages.StandardController ctlr = new ApexPages.StandardController(driverSurvey); SurveyForDriverController grabController=new SurveyForDriverController(ctlr); Test.startTest(); driverSurvey.Name='testuser1'; driverSurvey.Name__c='testuser1'; driverSurvey.Email__c='emailuser@testorg.com'; Driver_Survey__c driverSurvey1=new Driver_Survey__c(); ApexPages.StandardController ctlr1 = new ApexPages.StandardController(driverSurvey1); SurveyForDriverController grabController1=new SurveyForDriverController(ctlr1); driverSurvey1.Name__c='testuser2'; driverSurvey1.Email__c='emailuser@testorg.com'; driverSurvey1.Id=driverSurvey.id; update driverSurvey1; grabController.saveRecord(); Test.stopTest(); } }
Kindly help
Many thanks in advance
- Harjeet Singh 28
- September 18, 2019
- Like
- 0
Update failed.First exception on row 0 with id ,first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY,LeadTrigger: maximum trigger depth exceeded,Lead trigger event AfterUpdate
Hi All,
Recently I encoutered the issue of maximum trigger depth exceeded. The thing is functionality is working fine in sandboxes but somehow it is showing errors in PROD.
My functionality is to assign leads on round robin basis and during bulk upload it shows the errors
Below is my trigger
Below is my Apex class which assigns leads to users in round robin basis
What else I need to do here?How can I remove this error?
Any help will be greatly appreciated
Many thanks in advance
Recently I encoutered the issue of maximum trigger depth exceeded. The thing is functionality is working fine in sandboxes but somehow it is showing errors in PROD.
My functionality is to assign leads on round robin basis and during bulk upload it shows the errors
Below is my trigger
trigger LeadTrigger on Lead (before insert,before update,after insert,after update) { if(Trigger.isAfter){ if(trigger.isInsert || trigger.isUpdate){ RoundRobinImplementationHelper.roundRobinImplementation(Trigger.NewMap.keySet()); } } }
Below is my Apex class which assigns leads to users in round robin basis
public class RoundRobinImplementationHelper { public static void roundRobinImplementation(Set<Id> leadSet){ System.debug('roundRobinImplementation '); List<Lead> leadList = [Select Id, OwnerId, Lead_Number__c FROM Lead Where Id IN : leadSet]; List<User> userList = new List<User>(); Set<Id> queueIdSet = new Set<Id>(); Set<Id> userIdSet = new Set<Id>(); Integer index, leadNumber, teamSize; For(Lead leadIterate : leadList){ If(String.valueOf(leadIterate.ownerId).startsWith('00G')){ queueIdSet.add(leadIterate.ownerId); } } If(queueIdSet==null || queueIdSet.size()==0)return; System.debug('queueIdSet '+queueIdSet); For(GroupMember gm : [Select Id, UserOrGroupId FROM GROUPMEMBER WHERE GroupId IN : queueIdSet]){ userIdSet.add(gm.UserOrGroupId); } userList = [Select Id, Name, Profile.Name From User Where Id In : userIdSet AND ISACTIVE = true]; If(userList==null || userList.size()==0)return; For(Lead leadIterate : leadList){ if(leadIterate.Lead_Number__c!=null){ leadNumber = Integer.valueOf(leadIterate.Lead_Number__c); teamSize = userList.size(); index = Math.MOD(leadNumber ,teamSize);//+1; system.debug('index '+index); leadIterate.OwnerId = userList[index].id; system.debug('leadIterate.OwnerId '+ leadIterate.OwnerId); } } If(leadList!=null && leadList.size()>0){ update leadList; } } }
What else I need to do here?How can I remove this error?
Any help will be greatly appreciated
Many thanks in advance
- Harjeet Singh 28
- September 17, 2019
- Like
- 0
How I populate field values from a VF page to the site VF page
Hi All,
I have a VF page with standard controller and extension.This page basically used by salesforce user to enter the values.This form has an email field.Upon saving record an email should trigger to external user on the email id specified during record creation.The email whcih an external user receives will have link to the sites which we have created.Now when user copy paste the site link in browser tab then a new VF page will appear will some fields auto populate.
Basically my VF page is up and running.My site is up and running.For Salesforce users and external users I am displaying the same VF page with some sections (used renedring) but I am not able to auto populate the fieldson site VF.
Lets say in my vf page where salesforce users are entering values(name,email,mobile).When they save record the email will go to the email id specified during record creation. When external user receive email which will have link for the external site and go to that external site I want name and email field will be auto puplate this time and external user can only enter their mobile no
Below is snippet from my VF page():
I am not able to auto populate the name and email on the page which external user will see
Any help would be greatly appreciated
Kindly help
Mnay thanks in advance
I have a VF page with standard controller and extension.This page basically used by salesforce user to enter the values.This form has an email field.Upon saving record an email should trigger to external user on the email id specified during record creation.The email whcih an external user receives will have link to the sites which we have created.Now when user copy paste the site link in browser tab then a new VF page will appear will some fields auto populate.
Basically my VF page is up and running.My site is up and running.For Salesforce users and external users I am displaying the same VF page with some sections (used renedring) but I am not able to auto populate the fieldson site VF.
Lets say in my vf page where salesforce users are entering values(name,email,mobile).When they save record the email will go to the email id specified during record creation. When external user receive email which will have link for the external site and go to that external site I want name and email field will be auto puplate this time and external user can only enter their mobile no
Below is snippet from my VF page():
<apex:page standardController="Driver_Survey__c" extensions="SurveyForDriverController" sidebar="false" lightningStylesheets="true" showHeader="{! $Profile.Name == 'System Administrator' }" > <apex:form > <!--Below section will be sued by the Salesforce user to enther details and save record--> <apex:pageBlockSection columns="1" collapsible="false" title="Driver Information" rendered="{!IF($Profile.Name =='Profile1'|| $Profile.Name =='Profile2' , true, False)}" > <apex:inputField label="Name" value="{!survey.Name__c}" required="true"/> <apex:inputField label="Mobile" value="{!survey.Mobile__c}" required="true" /> <apex:inputField label="Email" value="{!survey.Email__c}" required="true" /> </apex:pageBlockSection> <!--Below section will be visible on Sites for external user--> <apex:pageBlockSection columns="1" collapsible="false" title="Driver Information" rendered="{!IF($Profile.Name=='Transport Questionnaire Profile',true,false)}" > <apex:inputField label="Name1" value="{!survey.Name__c}"/> <apex:outputField label="Mobile1" value="{!survey.Mobile__c}"/> <apex:outputField label="Email1" value="{!survey.Email__c}"/> </apex:pageBlockSection> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!doFullSave}" /> <apex:commandButton value="Cancel" action="{!doCancel}" immediate="true"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>Below is my controller(pasting only required snippet):
public class SurveyForDriverController{ //class variables public Driver_Survey__c survey{get;set;} Public String name{get;set;} Public String ordid; public GrabSurveyForDriverController(ApexPages.StandardController controller){ survey=new Grab_Driver_Survey__c(); survey=(Grab_Driver_Survey__c)controller.getRecord(); system.debug('message3>>'+survey ); Id profileId=userinfo.getProfileId(); String profileName=[Select Id,Name from Profile where Id=:profileId].Name; system.debug('ProfileName'+profileName); if(profileName=='Grab Transport Questionnaire Profile'){ survey.Name__c=ApexPages.currentPage().getParameters().get('ordid'); } } public PageReference doFullSave(){ system.debug('message1>>'+survey ); insert survey; SendEmail(); PageReference pageRef = new PageReference('/'+survey.Id); pageRef.setRedirect(true); return pageRef; } public PageReference doCancel(){ PageReference pageRef = new PageReference('/'); pageRef.setRedirect(true); return pageRef; } public void SendEmail(){ Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.toAddresses = new String[] { survey.Email__c }; mail.subject = 'Subject Test Message'; String body = 'Hi \n '; body += + survey.Name__c+ '<br><br>' ; body+= +'Request you to kindly fill in the questionnaire'+ '<br><br>'; body+= +'https://"My siteURL"/myVFpagename; mail.setHtmlBody(body); Messaging.SingleEmailMessage[] mailss = new List<Messaging.SingleEmailMessage> {mail}; Messaging.SendEmailResult[] results = Messaging.sendEmail(mailss); if (results[0].success) { System.debug('The email was sent successfully.'); } else { System.debug('The email failed to send: ' + results[0].errors[0].message); } } }
I am not able to auto populate the name and email on the page which external user will see
Any help would be greatly appreciated
Kindly help
Mnay thanks in advance
- Harjeet Singh 28
- September 13, 2019
- Like
- 0
Test Class Error:System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_EMAIL_ADDRESS, Email address is invalid: null: [toAddresses, null]
Hi All,
I have been stuck in test class and not getting a way to solve the issue.
I have a VF page and controller. VF page is basically an input form where an user can fill up their information and Save.Once Save the controller will exceute and save the record to a custom object.In input form I have an input field where user can key in their email address.Upon save an email should go to the email address which has been specified in email input field.Functionality is working fine though the issue is with the test class.I understand to test email messaging we need to ensure we are inserting the correct data/record which I am doing but upon running the test class I am getting error : System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_EMAIL_ADDRESS, Email address is invalid: null: [toAddresses, null]
Below is a part from my VF page:
Below is the Save function snippets:
Below is my test clas:
I am passing correct Email while creating the survey record but test class showing invalid toAddress,null
Any help would be greatly appreciated
Kindly help
Many thanks in advance
I have been stuck in test class and not getting a way to solve the issue.
I have a VF page and controller. VF page is basically an input form where an user can fill up their information and Save.Once Save the controller will exceute and save the record to a custom object.In input form I have an input field where user can key in their email address.Upon save an email should go to the email address which has been specified in email input field.Functionality is working fine though the issue is with the test class.I understand to test email messaging we need to ensure we are inserting the correct data/record which I am doing but upon running the test class I am getting error : System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_EMAIL_ADDRESS, Email address is invalid: null: [toAddresses, null]
Below is a part from my VF page:
<apex:page standardController="Driver_Survey__c" extensions="SurveyForDriverController" sidebar="false" lightningStylesheets="true"> <apex:form > <apex:pageBlock mode="edit" > <apex:pageBlockSection columns="1" collapsible="false" title="Driver Information" > <apex:inputField label="Name" value="{!survey.Name__c}" required="true"/> <apex:inputField label="Mobile" value="{!survey.Mobile__c}" required="true" /> <apex:inputField label="Email" value="{!survey.Email__c}" required="true" /> </apex:pageBlockSection> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!doFullSave}"/> <apex:commandButton value="Cancel" action="{!doCancel}" immediate="true"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
Below is the Save function snippets:
public class SurveyForDriverController{ public Driver_Survey__c survey{get;set;} public SurveyForDriverController(ApexPages.StandardController controller){ survey=new Driver_Survey__c(); } public PageReference doFullSave(){ system.debug('message1>>'+survey ); insert survey; Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.toAddresses = new String[] { survey.Email__c }; system.debug('message110>>'+mail.toAddresses ); mail.subject = 'Subject Test Message'; //mail.plainTextBody = 'This is a test mail'; String body = 'Hi \n '; body += + survey.Name__c+ '<br><br>' ; body+= +'Request you to kindly fill in the questionnaire'; mail.setHtmlBody(body); Messaging.SingleEmailMessage[] mailss = new List<Messaging.SingleEmailMessage> {mail}; Messaging.SendEmailResult[] results = Messaging.sendEmail(mailss); if (results[0].success) { System.debug('The email was sent successfully.'); } else { System.debug('The email failed to send: ' + results[0].errors[0].message); } PageReference pageRef = new PageReference('/'+survey.Id); pageRef.setRedirect(true); return pageRef; } public PageReference doCancel(){ PageReference pageRef = new PageReference('/'); pageRef.setRedirect(true); return pageRef; } }
Below is my test clas:
@isTest public class TestSurveyForDriverController { static testMethod void test () { Driver_Survey__c driverSurvey=new Driver_Survey__c(); driverSurvey.Customer_Experience__c='6'; driverSurvey.Email__c='test@test.com'; driverSurvey.Expected_Earnings_Weekly__c=10000; driverSurvey.How_long_have_you_been_working_there__c=6; driverSurvey.Will_you_be_planning_to_drive_for_Grab__c='Yes'; driverSurvey.Kind_of_car_are_you_using_Rental_Car__c='Honda City'; driverSurvey.Name='testuser1'; driverSurvey.Name__c='testuser1'; driverSurvey.Customer_Experience__c='All of the Above'; insert driverSurvey; ApexPages.StandardController ctlr = new ApexPages.StandardController(driverSurvey); GrabSurveyForDriverController grabController=new GrabSurveyForDriverController(ctlr); grabController.doFullSave(); grabController.doCancel(); } }
I am passing correct Email while creating the survey record but test class showing invalid toAddress,null
Any help would be greatly appreciated
Kindly help
Many thanks in advance
- Harjeet Singh 28
- September 10, 2019
- Like
- 0
Send an email to email address specified in email input field on VF page
Hi All,
I ahve created one input form where users can fill in their details and save records.The input form is a VF page and save record logic implemented in controller and everything works fine.
Now my issue is when the record is saved then an email should go to the email id specified in input form.This email id can be external also(not a salesforce user). If its a Salesforce user I can go with PB,Workflow rules/email alerts etc.
Below is my VF page
Below is my controller
Below is screenshot of the vf page
So whatever email id specified in the Email field above will receive an email upon the record save.
On VF Page I am using input field for Email and at object level I have Text field as "Email" to store the value from VF page to object
Kindly help
Many thanks in advance
I ahve created one input form where users can fill in their details and save records.The input form is a VF page and save record logic implemented in controller and everything works fine.
Now my issue is when the record is saved then an email should go to the email id specified in input form.This email id can be external also(not a salesforce user). If its a Salesforce user I can go with PB,Workflow rules/email alerts etc.
Below is my VF page
<apex:page standardController="Driver_Survey__c" extensions="GrabSurveyForDriverController" sidebar="false" lightningStylesheets="true"> <apex:form > <apex:pageBlock mode="edit" > <apex:pageBlockSection columns="1" collapsible="false" title="Driver Information" > <apex:inputField label="Name" value="{!survey.Name__c}" required="true"/> <apex:inputField label="Mobile" value="{!survey.Mobile__c}" required="true" /> <apex:inputField label="Email" value="{!survey.Email__c}" required="true" /> </apex:pageBlockSection> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!doFullSave}"/> <apex:commandButton value="Cancel" action="{!doCancel}" immediate="true"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
Below is my controller
public class SurveyForDriverController{ public Grab_Driver_Survey__c survey{get;set;} public SurveyForDriverController(ApexPages.StandardController controller){ survey=new Driver_Survey__c(); } public PageReference doFullSave(){ insert survey; system.debug('message110>>'+survey ); system.debug('message2>>'+survey ); PageReference pageRef = new PageReference('/'+survey.Id); pageRef.setRedirect(true); return pageRef; } public PageReference doCancel(){ PageReference pageRef = new PageReference('/'); pageRef.setRedirect(true); return pageRef; } }
Below is screenshot of the vf page
So whatever email id specified in the Email field above will receive an email upon the record save.
On VF Page I am using input field for Email and at object level I have Text field as "Email" to store the value from VF page to object
Kindly help
Many thanks in advance
- Harjeet Singh 28
- September 05, 2019
- Like
- 0
CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY:LeadTrigger: execution of AfterUpdate\ncaused by: System.DmlException: Update failed. First exception on row 0 with id first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, LeadTrigger: maximum trigger depth exceeded\
Hi All,
Recently I encoutered the issue of maximum trigger depth exceeded. The thing is functionality is working fine in sandboxes but somehow it is showing errors in PROD.
My functionality is to assign leads on round robin basis and during bulk upload it shows the errors
Below is my trigger
Below is my Apex class which assigns leads to users in round robin basis
What else I need to do here?How can I remove this error?
Any help will be greatly appreciated
Many thanks in advance
Recently I encoutered the issue of maximum trigger depth exceeded. The thing is functionality is working fine in sandboxes but somehow it is showing errors in PROD.
My functionality is to assign leads on round robin basis and during bulk upload it shows the errors
Below is my trigger
trigger LeadTrigger on Lead (before insert,before update,after insert,after update) { if(Trigger.isAfter){ if(trigger.isInsert || trigger.isUpdate){ RoundRobinImplementationHelper.roundRobinImplementation(Trigger.NewMap.keySet()); } } }
Below is my Apex class which assigns leads to users in round robin basis
public class RoundRobinImplementationHelper { public static void roundRobinImplementation(Set<Id> leadSet){ System.debug('roundRobinImplementation '); List<Lead> leadList = [Select Id, OwnerId, Lead_Number__c FROM Lead Where Id IN : leadSet]; List<User> userList = new List<User>(); Set<Id> queueIdSet = new Set<Id>(); Set<Id> userIdSet = new Set<Id>(); Integer index, leadNumber, teamSize; For(Lead leadIterate : leadList){ If(String.valueOf(leadIterate.ownerId).startsWith('00G')){ queueIdSet.add(leadIterate.ownerId); } } If(queueIdSet==null || queueIdSet.size()==0)return; System.debug('queueIdSet '+queueIdSet); For(GroupMember gm : [Select Id, UserOrGroupId FROM GROUPMEMBER WHERE GroupId IN : queueIdSet]){ userIdSet.add(gm.UserOrGroupId); } userList = [Select Id, Name, Profile.Name From User Where Id In : userIdSet AND ISACTIVE = true]; If(userList==null || userList.size()==0)return; For(Lead leadIterate : leadList){ if(leadIterate.Lead_Number__c!=null){ leadNumber = Integer.valueOf(leadIterate.Lead_Number__c); teamSize = userList.size(); index = Math.MOD(leadNumber ,teamSize);//+1; system.debug('index '+index); leadIterate.OwnerId = userList[index].id; system.debug('leadIterate.OwnerId '+ leadIterate.OwnerId); } } If(leadList!=null && leadList.size()>0){ update leadList; } } }
What else I need to do here?How can I remove this error?
Any help will be greatly appreciated
Many thanks in advance
- Harjeet Singh 28
- September 03, 2019
- Like
- 0
Insert failed. REQUIRED_FIELD_MISSING, Required fields are missing: [Version Data]: [Version Data]
Hi All,
I am working on a requiremenmt where I need to present users with an input form where they can fill up the details and then can upload files from their machine.
I have created the input forms but facing some issue for file upload functionality.I have a custom object and added the related list "Files".If user upload the document and save the record then record will be sdaved with their inputs and uploaded file can be seen under Files related list.
Actual problem comes up when user doesn't select/attach any file and directly click on save button then I am getting error "Insert failed. REQUIRED_FIELD_MISSING, Required fields are missing: [Version Data]: [Version Data]".Ideally I dont want user to necessarily upload a file.
Below is my VF Page
Below is my controller:
Summary of my problem statement:
1. When user enters the inputs in the form and upload the file and hit Save button then the record is getting created with the uploaded files under Files realted list-This is absolutely working fine
2. When an user enters the inputs in the form and doesn't select/upload any files and hit Save button then I am getting error "Insert failed. REQUIRED_FIELD_MISSING, Required fields are missing: [Version Data]: [Version Data]".Ideally it should also allows an user to save the record even if they don't want to upload any files
Kindly help
Many thanks in advance
I am working on a requiremenmt where I need to present users with an input form where they can fill up the details and then can upload files from their machine.
I have created the input forms but facing some issue for file upload functionality.I have a custom object and added the related list "Files".If user upload the document and save the record then record will be sdaved with their inputs and uploaded file can be seen under Files related list.
Actual problem comes up when user doesn't select/attach any file and directly click on save button then I am getting error "Insert failed. REQUIRED_FIELD_MISSING, Required fields are missing: [Version Data]: [Version Data]".Ideally I dont want user to necessarily upload a file.
Below is my VF Page
<!--<apex:page Controller="GrabSurveyForDriverController" sidebar="false" lightningStylesheets="true">--> <apex:page standardController="Grab_Driver_Survey__c" extensions="GrabSurveyForDriverController" sidebar="false" lightningStylesheets="true"> <apex:form > <apex:pageBlock mode="edit" > <apex:pageBlockSection columns="1" collapsible="false" title="Driver Information" > <apex:inputField label="Name" value="{!survey.Name__c}" required="true"/> <apex:inputField label="Mobile" value="{!survey.Mobile__c}" required="true" /> <apex:inputField label="Email" value="{!survey.Email__c}" required="true" /> </apex:pageBlockSection> <apex:pageBlockSection columns="2" collapsible="false" title="Fact Finding"> <!--<apex:pageBlockTable var="survey" value="{!surveyList}">--> <apex:inputField label="Reason for joining" value="{!survey.Reason_for_joining__c}"/> <apex:inputField label="What are you previously or currently working as?" value="{!survey.Previously_or_currently_working_as__c}" /> <apex:inputField label="How long have you been working there?" value="{!survey.How_long_have_you_been_working_there__c}" /> <apex:inputField label="Reason for leaving" value="{!survey.Reason_for_leaving__c}" /> <apex:inputField label="Previous or current salary range (per annum)" value="{!survey.Previous_or_current_salary_range_annum__c}" /> <apex:inputField label="How much do you expect to earn by driving (weekly)" value="{!survey.How_much_you_expect_to_earn_weekly__c}" /> <apex:inputField label="What car will you be using? " value="{!survey.What_car_will_you_be_using__c}" /> <apex:inputField label="How many hours are you able to drive in a day? " value="{!survey.How_many_hours_you_able_to_drive_a_day__c}" /> </apex:pageBlockSection> <apex:pageBlockSection columns="2" collapsible="false" title="Interview Questions" id="pbToRerender" > <apex:inputField label="What is your past records? (Demerit Points) " value="{!survey.What_is_your_past_driving_records__c}"/> <apex:actionRegion> <apex:inputField label="Any Criminal Records?(Yes/No)" value="{!survey.Any_Criminal_Records__c}" id="id1" > <apex:actionSupport event="onchange" rerender="pbToRerender"/> </apex:inputField> </apex:actionRegion> <!--<apex:inputField label="Reasons associated with Criminal Records" value="{!survey.Reasons_associated_with_Criminal_Records__c}" />--> <apex:inputField label="Are you currently employed or any other source of income (What job)" value="{!survey.Are_you_currently_employed_or_other_job__c}" /> </apex:pageBlockSection> <apex:inputFile value="{!file}" styleclass="slds-file-selector__input slds-assistive-text"/> <apex:pageBlockButtons > <apex:actionRegion > <apex:commandButton value="Save" action="{!doFullSave}"/> <apex:commandButton value="Cancel" action="{!doCancel}" immediate="true"/> </apex:actionRegion> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
Below is my controller:
public class GrabSurveyForDriverController{ public Grab_Driver_Survey__c survey{get;set;} public String newSurveyList {get;set;} public String newSurveyListSecond {get;set;} public String newSurveyListThird {get;set;} public String newSurveyListFourth {get;set;} public String newSurveyListFifth {get;set;} public blob file { get; set; } public string fileName{get;set;} public GrabSurveyForDriverController(ApexPages.StandardController controller){ survey=new Grab_Driver_Survey__c(); //ContentVersion v = new ContentVersion(); system.debug('message3>>'+survey ); } public PageReference doFullSave(){ system.debug('message1>>'+survey ); insert survey; ContentVersion conVer = new ContentVersion(); conVer.ContentLocation = 'S'; // S specify this document is in SF, use E for external files conVer.PathOnClient = 'file'; // The files name, extension is very important here which will help the file in preview. conVer.Title = 'fileName '; // Display name of the files conVer.VersionData = file; // converting your binary string to Blob insert conVer; Id conDoc = [SELECT Id,ContentDocumentId FROM ContentVersion WHERE Id =:conVer.Id].ContentDocumentId; //Create ContentDocumentLink ContentDocumentLink cDe = new ContentDocumentLink(); cDe.ContentDocumentId = conDoc; cDe.LinkedEntityId =survey.Id; // you can use objectId,GroupId etc cDe.ShareType = 'V'; // Inferred permission, checkout description of ContentDocumentLink object for more details cDe.Visibility = 'AllUsers'; insert cDe; PageReference pageRef = new PageReference('/'+survey.Id); pageRef.setRedirect(true); return pageRef; } public PageReference doCancel(){ PageReference pageRef = new PageReference('/'); pageRef.setRedirect(true); return pageRef; } }
Summary of my problem statement:
1. When user enters the inputs in the form and upload the file and hit Save button then the record is getting created with the uploaded files under Files realted list-This is absolutely working fine
2. When an user enters the inputs in the form and doesn't select/upload any files and hit Save button then I am getting error "Insert failed. REQUIRED_FIELD_MISSING, Required fields are missing: [Version Data]: [Version Data]".Ideally it should also allows an user to save the record even if they don't want to upload any files
Kindly help
Many thanks in advance
- Harjeet Singh 28
- August 30, 2019
- Like
- 0
How to upload a file and associate with the record in Files related List
Hi All,
I am working on a requiremenmt where I need to present users with an input form where they can fill up the details and then can upload files from their machine.
I have created the input forms but facing some issue for file upload functionality.I have an object and added the related list "Files" to the object but not able to link the uploaded file to the record.
Below is my VF Page
Below is my controller:
Any help would be greatly appreciated
Many thanks in advance
Thanks & Regards,
Harjeet
I am working on a requiremenmt where I need to present users with an input form where they can fill up the details and then can upload files from their machine.
I have created the input forms but facing some issue for file upload functionality.I have an object and added the related list "Files" to the object but not able to link the uploaded file to the record.
Below is my VF Page
<!--<apex:page Controller="GrabSurveyForDriverController" sidebar="false" lightningStylesheets="true">--> <apex:page standardController="Grab_Driver_Survey__c" extensions="GrabSurveyForDriverController" sidebar="false" lightningStylesheets="true"> <apex:form > <apex:pageBlock mode="edit" > <apex:pageBlockSection columns="1" collapsible="false" title="Driver Information" > <apex:inputField label="Name" value="{!survey.Name__c}" required="true"/> <apex:inputField label="Mobile" value="{!survey.Mobile__c}" required="true" /> <apex:inputField label="Email" value="{!survey.Email__c}" required="true" /> </apex:pageBlockSection> <apex:pageBlockSection columns="2" collapsible="false" title="Fact Finding"> <!--<apex:pageBlockTable var="survey" value="{!surveyList}">--> <apex:inputField label="Reason for joining" value="{!survey.Reason_for_joining__c}"/> <apex:inputField label="What are you previously or currently working as?" value="{!survey.Previously_or_currently_working_as__c}" /> <apex:inputField label="How long have you been working there?" value="{!survey.How_long_have_you_been_working_there__c}" /> <apex:inputField label="Reason for leaving" value="{!survey.Reason_for_leaving__c}" /> <apex:inputField label="Previous or current salary range (per annum)" value="{!survey.Previous_or_current_salary_range_annum__c}" /> <apex:inputField label="How much do you expect to earn by driving (weekly)" value="{!survey.How_much_you_expect_to_earn_weekly__c}" /> <apex:inputField label="What car will you be using? " value="{!survey.What_car_will_you_be_using__c}" /> <apex:inputField label="How many hours are you able to drive in a day? " value="{!survey.How_many_hours_you_able_to_drive_a_day__c}" /> </apex:pageBlockSection> <apex:pageBlockSection columns="2" collapsible="false" title="Interview Questions" id="pbToRerender" > <apex:inputField label="What is your past records? (Demerit Points) " value="{!survey.What_is_your_past_driving_records__c}"/> <apex:actionRegion> <apex:inputField label="Any Criminal Records?(Yes/No)" value="{!survey.Any_Criminal_Records__c}" id="id1" > <apex:actionSupport event="onchange" rerender="pbToRerender"/> </apex:inputField> </apex:actionRegion> <!--<apex:inputField label="Reasons associated with Criminal Records" value="{!survey.Reasons_associated_with_Criminal_Records__c}" />--> <apex:inputField label="Are you currently employed or any other source of income (What job)" value="{!survey.Are_you_currently_employed_or_other_job__c}" /> </apex:pageBlockSection> <apex:pageBlockButtons > <apex:actionRegion> <apex:commandButton value="Save" action="{!doFullSave}"/> <apex:commandButton value="Cancel" action="{!doCancel}" immediate="true"/> </apex:actionRegion> </apex:pageBlockButtons> <!--<apex:inputFile value="{!file}" filename="{!fileName}"/> <apex:commandbutton action="{!upload}" value="Upload" /> --> </apex:pageBlock> <apex:inputFile value="{!file}"/> <apex:commandbutton action="{!upload}" value="Upload" /> </apex:form> </apex:page>
Below is my controller:
public class GrabSurveyForDriverController{ public Grab_Driver_Survey__c survey{get;set;} public String newSurveyList {get;set;} public String newSurveyListSecond {get;set;} public String newSurveyListThird {get;set;} public String newSurveyListFourth {get;set;} public String newSurveyListFifth {get;set;} public blob file { get; set; } public string fileName{get;set;} public GrabSurveyForDriverController(ApexPages.StandardController controller){ survey=new Grab_Driver_Survey__c(); //ContentVersion v = new ContentVersion(); system.debug('message3>>'+survey ); } public PageReference doFullSave(){ system.debug('message1>>'+survey ); insert survey; system.debug('message2>>'+survey ); PageReference pageRef = new PageReference('/'+survey.Id); pageRef.setRedirect(true); return pageRef; } public PageReference doCancel(){ PageReference pageRef = new PageReference('/'); pageRef.setRedirect(true); return pageRef; } public void upload() { system.debug('message21>>'+file ); ContentVersion conVer = new ContentVersion(); conVer.ContentLocation = 'S'; // S specify this document is in SF, use E for external files conVer.PathOnClient = 'ionicLogo.png'; // The files name, extension is very important here which will help the file in preview. conVer.Title = 'Proposal '; // Display name of the files conVer.VersionData = file; // converting your binary string to Blob insert conVer; Id conDoc = [SELECT ContentDocumentId FROM ContentVersion WHERE Id =:conVer.Id].ContentDocumentId; //Create ContentDocumentLink ContentDocumentLink cDe = new ContentDocumentLink(); cDe.ContentDocumentId = conDoc; cDe.LinkedEntityId = survey.Id; cDe.ShareType = 'V'; // Inferred permission, checkout description of ContentDocumentLink object for more details cDe.Visibility = 'InternalUsers'; insert cDe; } }
Any help would be greatly appreciated
Many thanks in advance
Thanks & Regards,
Harjeet
- Harjeet Singh 28
- August 29, 2019
- Like
- 0
Custom Lead Conversion to specific oppty record types
Hi All,
I need to auto convert a lead to oppty where converted oppty record type will depend upon the fields on leads.
My use case is something like below:
Let's say I have 2checkbox fields on leads checkbox 1 and checkbox 2.
So if I select checkbox1 then lead will convert to oppty with recordtype1
And if I select checkbox2 then lead will convert to oppty with recordtype2
Assume recordtype1 and recordtype2 exists on oppty. Also there are validations in place to ensure user can't select both checkboxes(which I have already created)
What are my options available to achieve the above?
I am aware about lead conversion using Process builder which invokes an invocable method in an Apex class and convert the leads to res account, contact and opportunity but I am not sure how can I set the record type of opportunity while conversion
Kindly help
Many thanks in advance
Thanks & Regards,
Harjeet
I need to auto convert a lead to oppty where converted oppty record type will depend upon the fields on leads.
My use case is something like below:
Let's say I have 2checkbox fields on leads checkbox 1 and checkbox 2.
So if I select checkbox1 then lead will convert to oppty with recordtype1
And if I select checkbox2 then lead will convert to oppty with recordtype2
Assume recordtype1 and recordtype2 exists on oppty. Also there are validations in place to ensure user can't select both checkboxes(which I have already created)
What are my options available to achieve the above?
I am aware about lead conversion using Process builder which invokes an invocable method in an Apex class and convert the leads to res account, contact and opportunity but I am not sure how can I set the record type of opportunity while conversion
Kindly help
Many thanks in advance
Thanks & Regards,
Harjeet
- Harjeet Singh 28
- August 20, 2019
- Like
- 0
Help for test class coverage
Hi All,
I have developed an apex class whcih basically assign users to queue dynamically.I have a VF page which will launch from a custom VF tab.This VF page shows few users and with the checkbox.When checkbox against the username is marked and hit Save button then seleected users will go to the queue defined in class.
Below is my clas:
I am not able to cover below lines of code:
My current code coverage stands at 73%
Many I request to help me on same to get a code coverage above 75%
Many thanks in advance
Thanks & Regards,
Harjeet
I have developed an apex class whcih basically assign users to queue dynamically.I have a VF page which will launch from a custom VF tab.This VF page shows few users and with the checkbox.When checkbox against the username is marked and hit Save button then seleected users will go to the queue defined in class.
Below is my clas:
public class TodayTelesalesDetails { public Date Today { get { return Date.today(); } } public List<wrapAgent> wrapAgentList{get; set;} public List<User> selectedAgents{get;set;} public TodayTelesalesDetails (){ if(wrapAgentList == null) { wrapAgentList = new List<wrapAgent>(); for(User teleSalesAgent: [select Id, Name, Email from User where Name IN('Steve Waugh','Yuvraj Singh')]) { // As each agent is processed we create a new wrap object and add it to the wrapAgentList wrapAgentList.add(new wrapAgent(teleSalesAgent)); } } } public PageReference doFullSave(){ set<id> userSetId = new set<id>(); list<GroupMember> gmm = new list<GroupMember>(); List<GroupMember> toBeDeleted= [SELECT Id, GroupId, UserOrGroupId FROM GroupMember where GroupId = '00G9D000000toPYUAY']; delete toBeDeleted; List<User> userlist=[select Id, Name from User where Name IN('Steve Waugh','Yuvraj Singh')]; for(User u : userlist) { system.debug('message3>>'+u); for(wrapAgent wrapAccountObj : wrapAgentList) { if(wrapAccountObj.selected == true) { userSetId.add(wrapAccountObj.teleAgent.id); } } } for(User us : [select id from User where id =: userSetId]) { for(Group gg : [select id,name from Group where type = 'Queue' and Name = 'TeleSales Queue']) { GroupMember gm = new GroupMember(); gm.groupId = gg.id; gm.UserOrGroupId = us.Id; gmm.add(gm); } } insert gmm; PageReference pageRef = new PageReference('/'); pageRef.setRedirect(true); return pageRef; } public PageReference doCancel(){ PageReference pageRef = new PageReference('/'); pageRef.setRedirect(true); return pageRef; } public class wrapAgent{ public User teleAgent {get; set;}//Please put the custom metadata names public Boolean selected {get; set;} //This is the contructor method. When we create a new object we pass a telesales metadata member that is set to the acc property. We also set the selected value to false public wrapAgent(User teleSalesAgent) { teleAgent = teleSalesAgent; selected = false; } } }and below is my test class:
@isTest public class Test_TodayTeleSalesDetails { public static testMethod void validateusersinqueue() { Group testGroup = new Group(Name='test group', Type='Queue'); insert testGroup; System.runAs(new User(Id=UserInfo.getUserId())) { QueuesObject testQueue = new QueueSObject(QueueID = testGroup.id, SObjectType = 'Lead'); insert testQueue; } Test.startTest(); TodayTelesalesDetails telesalesDetails=new TodayTelesalesDetails(); telesalesDetails.doFullSave(); telesalesDetails.doCancel(); Test.stopTest(); } }
I am not able to cover below lines of code:
for(User us : [select id from User where id =: userSetId]) { system.debug('message6>>'+us); for(Group gg : [select id,name from Group where type = 'Queue' and Name = 'TeleSales Queue']) { GroupMember gm = new GroupMember(); gm.groupId = gg.id; gm.UserOrGroupId = us.Id; gmm.add(gm); } }Below is the screenshot for the same:
My current code coverage stands at 73%
Many I request to help me on same to get a code coverage above 75%
Many thanks in advance
Thanks & Regards,
Harjeet
- Harjeet Singh 28
- August 19, 2019
- Like
- 1
Help for test class coverage
Hi All,
I have developed an apex class whcih basically assign users to queue dynamically.I have a VF page which will launch from a custom VF tab.This VF page shows few users and with the checkbox.When checkbox against the username is marked and hit Save button then seleected users will go to the queue defined in class.
Below is my clas:
I am not able to cover below lines of code:
My current code coverage stands at 73%
Many I request to help me on same to get a code coverage above 75%
Many thanks in advance
Thanks & Regards,
Harjeet
I have developed an apex class whcih basically assign users to queue dynamically.I have a VF page which will launch from a custom VF tab.This VF page shows few users and with the checkbox.When checkbox against the username is marked and hit Save button then seleected users will go to the queue defined in class.
Below is my clas:
public class TodayTelesalesDetails { public Date Today { get { return Date.today(); } } public List<wrapAgent> wrapAgentList{get; set;} public List<User> selectedAgents{get;set;} public TodayTelesalesDetails (){ if(wrapAgentList == null) { wrapAgentList = new List<wrapAgent>(); for(User teleSalesAgent: [select Id, Name, Email from User where Name IN('Steve Waugh','Yuvraj Singh')]) { // As each agent is processed we create a new wrap object and add it to the wrapAgentList wrapAgentList.add(new wrapAgent(teleSalesAgent)); } } } public PageReference doFullSave(){ set<id> userSetId = new set<id>(); list<GroupMember> gmm = new list<GroupMember>(); List<GroupMember> toBeDeleted= [SELECT Id, GroupId, UserOrGroupId FROM GroupMember where GroupId = '00G9D000000toPYUAY']; delete toBeDeleted; List<User> userlist=[select Id, Name from User where Name IN('Steve Waugh','Yuvraj Singh')]; for(User u : userlist) { system.debug('message3>>'+u); for(wrapAgent wrapAccountObj : wrapAgentList) { if(wrapAccountObj.selected == true) { userSetId.add(wrapAccountObj.teleAgent.id); } } } for(User us : [select id from User where id =: userSetId]) { for(Group gg : [select id,name from Group where type = 'Queue' and Name = 'TeleSales Queue']) { GroupMember gm = new GroupMember(); gm.groupId = gg.id; gm.UserOrGroupId = us.Id; gmm.add(gm); } } insert gmm; PageReference pageRef = new PageReference('/'); pageRef.setRedirect(true); return pageRef; } public PageReference doCancel(){ PageReference pageRef = new PageReference('/'); pageRef.setRedirect(true); return pageRef; } public class wrapAgent{ public User teleAgent {get; set;}//Please put the custom metadata names public Boolean selected {get; set;} //This is the contructor method. When we create a new object we pass a telesales metadata member that is set to the acc property. We also set the selected value to false public wrapAgent(User teleSalesAgent) { teleAgent = teleSalesAgent; selected = false; } } }and below is my test class:
@isTest public class Test_TodayTeleSalesDetails { public static testMethod void validateusersinqueue() { Group testGroup = new Group(Name='test group', Type='Queue'); insert testGroup; System.runAs(new User(Id=UserInfo.getUserId())) { QueuesObject testQueue = new QueueSObject(QueueID = testGroup.id, SObjectType = 'Lead'); insert testQueue; } Test.startTest(); TodayTelesalesDetails telesalesDetails=new TodayTelesalesDetails(); telesalesDetails.doFullSave(); telesalesDetails.doCancel(); Test.stopTest(); } }
I am not able to cover below lines of code:
for(User us : [select id from User where id =: userSetId]) { system.debug('message6>>'+us); for(Group gg : [select id,name from Group where type = 'Queue' and Name = 'TeleSales Queue']) { GroupMember gm = new GroupMember(); gm.groupId = gg.id; gm.UserOrGroupId = us.Id; gmm.add(gm); } }Below is the screenshot for the same:
My current code coverage stands at 73%
Many I request to help me on same to get a code coverage above 75%
Many thanks in advance
Thanks & Regards,
Harjeet
- Harjeet Singh 28
- August 19, 2019
- Like
- 1
How to share a file/document to non-salesforce users(user outside the org like legal team,customers)
Hi Experts,
I am looking for an advise/suggestion/guide on one of my requirement for which I haven't found a reliable solution yet
I am trying to implememt a functionality where I can share the files/documents on Salesforce to non-salesforce users(users outside my company) so that they can access the files outside.
I just wanted to understand if I can do this for non salesforce users? If yes what is the best way can we do this one?
Any help will be greatly appreciated
Many thanks in advance
Thanks & Regards,
Harjeet
I am looking for an advise/suggestion/guide on one of my requirement for which I haven't found a reliable solution yet
I am trying to implememt a functionality where I can share the files/documents on Salesforce to non-salesforce users(users outside my company) so that they can access the files outside.
I just wanted to understand if I can do this for non salesforce users? If yes what is the best way can we do this one?
Any help will be greatly appreciated
Many thanks in advance
Thanks & Regards,
Harjeet
- Harjeet Singh 28
- March 10, 2020
- Like
- 0
System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: [] test class
Hi All,
I have been stuck in test class and not getting a way to solve the issue.Upon running the test class I am getting error :System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []
Below is the CONTROLLER snippets:
Below is my test clas:
Kindly help
Many thanks in advance
I have been stuck in test class and not getting a way to solve the issue.Upon running the test class I am getting error :System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []
Below is the CONTROLLER snippets:
public class SurveyForDriverController{ //class variables public Driver_Survey__c survey{get;set;} public String newSurveyList {get;set;} public String newSurveyListSecond {get;set;} public String newSurveyListThird {get;set;} public String newSurveyListFourth {get;set;} public String newSurveyListFifth {get;set;} public SurveyForDriverController(ApexPages.StandardController controller){ system.debug('message3>>****'+ApexPages.currentPage().getParameters().get('recordID') ); if (ApexPages.currentPage().getParameters().get('recordID') !=null) survey = [SELECT Id, Name__c, Mobile__c, Email__c, from Driver_Survey__c where id = :ApexPages.currentPage().getParameters().get('recordID') ]; else survey=new Grab_Driver_Survey__c(); } public PageReference doFullSave(){ survey.Customer_Experience__c=newSurveyList; insert survey; PageReference pageRef = new PageReference('/'+survey.Id); pageRef.setRedirect(true); return pageRef; } public PageReference saveRecord( ) { survey.Customer_Experience__c=newSurveyList; update survey; return Page.DriverSurveyThankyouVF; } public void doCancel(){ PageReference pageRef = new PageReference('/'); pageRef.setRedirect(true); } }
Below is my test clas:
@isTest public class TestSurveyForDriverController { static testMethod void testForSalesforceUsers () { Profile p = [SELECT Id FROM Profile WHERE Name='Standard User']; Driver_Survey__c driverSurvey=new Driver_Survey__c(); ApexPages.StandardController ctlr = new ApexPages.StandardController(driverSurvey); SurveyForDriverController grabController=new SurveyForDriverController(ctlr); Test.startTest(); grabController.survey.Customer_Experience__c='6'; grabController.survey.Email__c='test@test.com'; grabController.survey.Expected_Earnings_Weekly__c=10000; grabController.survey.Name='testuser1'; grabController.survey.Name__c='testuser1'; grabController.doFullSave(); grabController.doCancel(); Test.stopTest(); } static testMethod void testForExternalUsers () { Profile p = [SELECT Id FROM Profile WHERE Name='Transport Questionnaire Profile']; Driver_Survey__c driverSurvey=new Driver_Survey__c(); ApexPages.StandardController ctlr = new ApexPages.StandardController(driverSurvey); SurveyForDriverController grabController=new SurveyForDriverController(ctlr); Test.startTest(); driverSurvey.Name='testuser1'; driverSurvey.Name__c='testuser1'; driverSurvey.Email__c='emailuser@testorg.com'; Driver_Survey__c driverSurvey1=new Driver_Survey__c(); ApexPages.StandardController ctlr1 = new ApexPages.StandardController(driverSurvey1); SurveyForDriverController grabController1=new SurveyForDriverController(ctlr1); driverSurvey1.Name__c='testuser2'; driverSurvey1.Email__c='emailuser@testorg.com'; driverSurvey1.Id=driverSurvey.id; update driverSurvey1; grabController.saveRecord(); Test.stopTest(); } }
Kindly help
Many thanks in advance
- Harjeet Singh 28
- September 18, 2019
- Like
- 0
How I populate field values from a VF page to the site VF page
Hi All,
I have a VF page with standard controller and extension.This page basically used by salesforce user to enter the values.This form has an email field.Upon saving record an email should trigger to external user on the email id specified during record creation.The email whcih an external user receives will have link to the sites which we have created.Now when user copy paste the site link in browser tab then a new VF page will appear will some fields auto populate.
Basically my VF page is up and running.My site is up and running.For Salesforce users and external users I am displaying the same VF page with some sections (used renedring) but I am not able to auto populate the fieldson site VF.
Lets say in my vf page where salesforce users are entering values(name,email,mobile).When they save record the email will go to the email id specified during record creation. When external user receive email which will have link for the external site and go to that external site I want name and email field will be auto puplate this time and external user can only enter their mobile no
Below is snippet from my VF page():
I am not able to auto populate the name and email on the page which external user will see
Any help would be greatly appreciated
Kindly help
Mnay thanks in advance
I have a VF page with standard controller and extension.This page basically used by salesforce user to enter the values.This form has an email field.Upon saving record an email should trigger to external user on the email id specified during record creation.The email whcih an external user receives will have link to the sites which we have created.Now when user copy paste the site link in browser tab then a new VF page will appear will some fields auto populate.
Basically my VF page is up and running.My site is up and running.For Salesforce users and external users I am displaying the same VF page with some sections (used renedring) but I am not able to auto populate the fieldson site VF.
Lets say in my vf page where salesforce users are entering values(name,email,mobile).When they save record the email will go to the email id specified during record creation. When external user receive email which will have link for the external site and go to that external site I want name and email field will be auto puplate this time and external user can only enter their mobile no
Below is snippet from my VF page():
<apex:page standardController="Driver_Survey__c" extensions="SurveyForDriverController" sidebar="false" lightningStylesheets="true" showHeader="{! $Profile.Name == 'System Administrator' }" > <apex:form > <!--Below section will be sued by the Salesforce user to enther details and save record--> <apex:pageBlockSection columns="1" collapsible="false" title="Driver Information" rendered="{!IF($Profile.Name =='Profile1'|| $Profile.Name =='Profile2' , true, False)}" > <apex:inputField label="Name" value="{!survey.Name__c}" required="true"/> <apex:inputField label="Mobile" value="{!survey.Mobile__c}" required="true" /> <apex:inputField label="Email" value="{!survey.Email__c}" required="true" /> </apex:pageBlockSection> <!--Below section will be visible on Sites for external user--> <apex:pageBlockSection columns="1" collapsible="false" title="Driver Information" rendered="{!IF($Profile.Name=='Transport Questionnaire Profile',true,false)}" > <apex:inputField label="Name1" value="{!survey.Name__c}"/> <apex:outputField label="Mobile1" value="{!survey.Mobile__c}"/> <apex:outputField label="Email1" value="{!survey.Email__c}"/> </apex:pageBlockSection> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!doFullSave}" /> <apex:commandButton value="Cancel" action="{!doCancel}" immediate="true"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>Below is my controller(pasting only required snippet):
public class SurveyForDriverController{ //class variables public Driver_Survey__c survey{get;set;} Public String name{get;set;} Public String ordid; public GrabSurveyForDriverController(ApexPages.StandardController controller){ survey=new Grab_Driver_Survey__c(); survey=(Grab_Driver_Survey__c)controller.getRecord(); system.debug('message3>>'+survey ); Id profileId=userinfo.getProfileId(); String profileName=[Select Id,Name from Profile where Id=:profileId].Name; system.debug('ProfileName'+profileName); if(profileName=='Grab Transport Questionnaire Profile'){ survey.Name__c=ApexPages.currentPage().getParameters().get('ordid'); } } public PageReference doFullSave(){ system.debug('message1>>'+survey ); insert survey; SendEmail(); PageReference pageRef = new PageReference('/'+survey.Id); pageRef.setRedirect(true); return pageRef; } public PageReference doCancel(){ PageReference pageRef = new PageReference('/'); pageRef.setRedirect(true); return pageRef; } public void SendEmail(){ Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.toAddresses = new String[] { survey.Email__c }; mail.subject = 'Subject Test Message'; String body = 'Hi \n '; body += + survey.Name__c+ '<br><br>' ; body+= +'Request you to kindly fill in the questionnaire'+ '<br><br>'; body+= +'https://"My siteURL"/myVFpagename; mail.setHtmlBody(body); Messaging.SingleEmailMessage[] mailss = new List<Messaging.SingleEmailMessage> {mail}; Messaging.SendEmailResult[] results = Messaging.sendEmail(mailss); if (results[0].success) { System.debug('The email was sent successfully.'); } else { System.debug('The email failed to send: ' + results[0].errors[0].message); } } }
I am not able to auto populate the name and email on the page which external user will see
Any help would be greatly appreciated
Kindly help
Mnay thanks in advance
- Harjeet Singh 28
- September 13, 2019
- Like
- 0
Test Class Error:System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_EMAIL_ADDRESS, Email address is invalid: null: [toAddresses, null]
Hi All,
I have been stuck in test class and not getting a way to solve the issue.
I have a VF page and controller. VF page is basically an input form where an user can fill up their information and Save.Once Save the controller will exceute and save the record to a custom object.In input form I have an input field where user can key in their email address.Upon save an email should go to the email address which has been specified in email input field.Functionality is working fine though the issue is with the test class.I understand to test email messaging we need to ensure we are inserting the correct data/record which I am doing but upon running the test class I am getting error : System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_EMAIL_ADDRESS, Email address is invalid: null: [toAddresses, null]
Below is a part from my VF page:
Below is the Save function snippets:
Below is my test clas:
I am passing correct Email while creating the survey record but test class showing invalid toAddress,null
Any help would be greatly appreciated
Kindly help
Many thanks in advance
I have been stuck in test class and not getting a way to solve the issue.
I have a VF page and controller. VF page is basically an input form where an user can fill up their information and Save.Once Save the controller will exceute and save the record to a custom object.In input form I have an input field where user can key in their email address.Upon save an email should go to the email address which has been specified in email input field.Functionality is working fine though the issue is with the test class.I understand to test email messaging we need to ensure we are inserting the correct data/record which I am doing but upon running the test class I am getting error : System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_EMAIL_ADDRESS, Email address is invalid: null: [toAddresses, null]
Below is a part from my VF page:
<apex:page standardController="Driver_Survey__c" extensions="SurveyForDriverController" sidebar="false" lightningStylesheets="true"> <apex:form > <apex:pageBlock mode="edit" > <apex:pageBlockSection columns="1" collapsible="false" title="Driver Information" > <apex:inputField label="Name" value="{!survey.Name__c}" required="true"/> <apex:inputField label="Mobile" value="{!survey.Mobile__c}" required="true" /> <apex:inputField label="Email" value="{!survey.Email__c}" required="true" /> </apex:pageBlockSection> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!doFullSave}"/> <apex:commandButton value="Cancel" action="{!doCancel}" immediate="true"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
Below is the Save function snippets:
public class SurveyForDriverController{ public Driver_Survey__c survey{get;set;} public SurveyForDriverController(ApexPages.StandardController controller){ survey=new Driver_Survey__c(); } public PageReference doFullSave(){ system.debug('message1>>'+survey ); insert survey; Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.toAddresses = new String[] { survey.Email__c }; system.debug('message110>>'+mail.toAddresses ); mail.subject = 'Subject Test Message'; //mail.plainTextBody = 'This is a test mail'; String body = 'Hi \n '; body += + survey.Name__c+ '<br><br>' ; body+= +'Request you to kindly fill in the questionnaire'; mail.setHtmlBody(body); Messaging.SingleEmailMessage[] mailss = new List<Messaging.SingleEmailMessage> {mail}; Messaging.SendEmailResult[] results = Messaging.sendEmail(mailss); if (results[0].success) { System.debug('The email was sent successfully.'); } else { System.debug('The email failed to send: ' + results[0].errors[0].message); } PageReference pageRef = new PageReference('/'+survey.Id); pageRef.setRedirect(true); return pageRef; } public PageReference doCancel(){ PageReference pageRef = new PageReference('/'); pageRef.setRedirect(true); return pageRef; } }
Below is my test clas:
@isTest public class TestSurveyForDriverController { static testMethod void test () { Driver_Survey__c driverSurvey=new Driver_Survey__c(); driverSurvey.Customer_Experience__c='6'; driverSurvey.Email__c='test@test.com'; driverSurvey.Expected_Earnings_Weekly__c=10000; driverSurvey.How_long_have_you_been_working_there__c=6; driverSurvey.Will_you_be_planning_to_drive_for_Grab__c='Yes'; driverSurvey.Kind_of_car_are_you_using_Rental_Car__c='Honda City'; driverSurvey.Name='testuser1'; driverSurvey.Name__c='testuser1'; driverSurvey.Customer_Experience__c='All of the Above'; insert driverSurvey; ApexPages.StandardController ctlr = new ApexPages.StandardController(driverSurvey); GrabSurveyForDriverController grabController=new GrabSurveyForDriverController(ctlr); grabController.doFullSave(); grabController.doCancel(); } }
I am passing correct Email while creating the survey record but test class showing invalid toAddress,null
Any help would be greatly appreciated
Kindly help
Many thanks in advance
- Harjeet Singh 28
- September 10, 2019
- Like
- 0
Send an email to email address specified in email input field on VF page
Hi All,
I ahve created one input form where users can fill in their details and save records.The input form is a VF page and save record logic implemented in controller and everything works fine.
Now my issue is when the record is saved then an email should go to the email id specified in input form.This email id can be external also(not a salesforce user). If its a Salesforce user I can go with PB,Workflow rules/email alerts etc.
Below is my VF page
Below is my controller
Below is screenshot of the vf page
So whatever email id specified in the Email field above will receive an email upon the record save.
On VF Page I am using input field for Email and at object level I have Text field as "Email" to store the value from VF page to object
Kindly help
Many thanks in advance
I ahve created one input form where users can fill in their details and save records.The input form is a VF page and save record logic implemented in controller and everything works fine.
Now my issue is when the record is saved then an email should go to the email id specified in input form.This email id can be external also(not a salesforce user). If its a Salesforce user I can go with PB,Workflow rules/email alerts etc.
Below is my VF page
<apex:page standardController="Driver_Survey__c" extensions="GrabSurveyForDriverController" sidebar="false" lightningStylesheets="true"> <apex:form > <apex:pageBlock mode="edit" > <apex:pageBlockSection columns="1" collapsible="false" title="Driver Information" > <apex:inputField label="Name" value="{!survey.Name__c}" required="true"/> <apex:inputField label="Mobile" value="{!survey.Mobile__c}" required="true" /> <apex:inputField label="Email" value="{!survey.Email__c}" required="true" /> </apex:pageBlockSection> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!doFullSave}"/> <apex:commandButton value="Cancel" action="{!doCancel}" immediate="true"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
Below is my controller
public class SurveyForDriverController{ public Grab_Driver_Survey__c survey{get;set;} public SurveyForDriverController(ApexPages.StandardController controller){ survey=new Driver_Survey__c(); } public PageReference doFullSave(){ insert survey; system.debug('message110>>'+survey ); system.debug('message2>>'+survey ); PageReference pageRef = new PageReference('/'+survey.Id); pageRef.setRedirect(true); return pageRef; } public PageReference doCancel(){ PageReference pageRef = new PageReference('/'); pageRef.setRedirect(true); return pageRef; } }
Below is screenshot of the vf page
So whatever email id specified in the Email field above will receive an email upon the record save.
On VF Page I am using input field for Email and at object level I have Text field as "Email" to store the value from VF page to object
Kindly help
Many thanks in advance
- Harjeet Singh 28
- September 05, 2019
- Like
- 0
CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY:LeadTrigger: execution of AfterUpdate\ncaused by: System.DmlException: Update failed. First exception on row 0 with id first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, LeadTrigger: maximum trigger depth exceeded\
Hi All,
Recently I encoutered the issue of maximum trigger depth exceeded. The thing is functionality is working fine in sandboxes but somehow it is showing errors in PROD.
My functionality is to assign leads on round robin basis and during bulk upload it shows the errors
Below is my trigger
Below is my Apex class which assigns leads to users in round robin basis
What else I need to do here?How can I remove this error?
Any help will be greatly appreciated
Many thanks in advance
Recently I encoutered the issue of maximum trigger depth exceeded. The thing is functionality is working fine in sandboxes but somehow it is showing errors in PROD.
My functionality is to assign leads on round robin basis and during bulk upload it shows the errors
Below is my trigger
trigger LeadTrigger on Lead (before insert,before update,after insert,after update) { if(Trigger.isAfter){ if(trigger.isInsert || trigger.isUpdate){ RoundRobinImplementationHelper.roundRobinImplementation(Trigger.NewMap.keySet()); } } }
Below is my Apex class which assigns leads to users in round robin basis
public class RoundRobinImplementationHelper { public static void roundRobinImplementation(Set<Id> leadSet){ System.debug('roundRobinImplementation '); List<Lead> leadList = [Select Id, OwnerId, Lead_Number__c FROM Lead Where Id IN : leadSet]; List<User> userList = new List<User>(); Set<Id> queueIdSet = new Set<Id>(); Set<Id> userIdSet = new Set<Id>(); Integer index, leadNumber, teamSize; For(Lead leadIterate : leadList){ If(String.valueOf(leadIterate.ownerId).startsWith('00G')){ queueIdSet.add(leadIterate.ownerId); } } If(queueIdSet==null || queueIdSet.size()==0)return; System.debug('queueIdSet '+queueIdSet); For(GroupMember gm : [Select Id, UserOrGroupId FROM GROUPMEMBER WHERE GroupId IN : queueIdSet]){ userIdSet.add(gm.UserOrGroupId); } userList = [Select Id, Name, Profile.Name From User Where Id In : userIdSet AND ISACTIVE = true]; If(userList==null || userList.size()==0)return; For(Lead leadIterate : leadList){ if(leadIterate.Lead_Number__c!=null){ leadNumber = Integer.valueOf(leadIterate.Lead_Number__c); teamSize = userList.size(); index = Math.MOD(leadNumber ,teamSize);//+1; system.debug('index '+index); leadIterate.OwnerId = userList[index].id; system.debug('leadIterate.OwnerId '+ leadIterate.OwnerId); } } If(leadList!=null && leadList.size()>0){ update leadList; } } }
What else I need to do here?How can I remove this error?
Any help will be greatly appreciated
Many thanks in advance
- Harjeet Singh 28
- September 03, 2019
- Like
- 0
Help for test class coverage
Hi All,
I have developed an apex class whcih basically assign users to queue dynamically.I have a VF page which will launch from a custom VF tab.This VF page shows few users and with the checkbox.When checkbox against the username is marked and hit Save button then seleected users will go to the queue defined in class.
Below is my clas:
I am not able to cover below lines of code:
My current code coverage stands at 73%
Many I request to help me on same to get a code coverage above 75%
Many thanks in advance
Thanks & Regards,
Harjeet
I have developed an apex class whcih basically assign users to queue dynamically.I have a VF page which will launch from a custom VF tab.This VF page shows few users and with the checkbox.When checkbox against the username is marked and hit Save button then seleected users will go to the queue defined in class.
Below is my clas:
public class TodayTelesalesDetails { public Date Today { get { return Date.today(); } } public List<wrapAgent> wrapAgentList{get; set;} public List<User> selectedAgents{get;set;} public TodayTelesalesDetails (){ if(wrapAgentList == null) { wrapAgentList = new List<wrapAgent>(); for(User teleSalesAgent: [select Id, Name, Email from User where Name IN('Steve Waugh','Yuvraj Singh')]) { // As each agent is processed we create a new wrap object and add it to the wrapAgentList wrapAgentList.add(new wrapAgent(teleSalesAgent)); } } } public PageReference doFullSave(){ set<id> userSetId = new set<id>(); list<GroupMember> gmm = new list<GroupMember>(); List<GroupMember> toBeDeleted= [SELECT Id, GroupId, UserOrGroupId FROM GroupMember where GroupId = '00G9D000000toPYUAY']; delete toBeDeleted; List<User> userlist=[select Id, Name from User where Name IN('Steve Waugh','Yuvraj Singh')]; for(User u : userlist) { system.debug('message3>>'+u); for(wrapAgent wrapAccountObj : wrapAgentList) { if(wrapAccountObj.selected == true) { userSetId.add(wrapAccountObj.teleAgent.id); } } } for(User us : [select id from User where id =: userSetId]) { for(Group gg : [select id,name from Group where type = 'Queue' and Name = 'TeleSales Queue']) { GroupMember gm = new GroupMember(); gm.groupId = gg.id; gm.UserOrGroupId = us.Id; gmm.add(gm); } } insert gmm; PageReference pageRef = new PageReference('/'); pageRef.setRedirect(true); return pageRef; } public PageReference doCancel(){ PageReference pageRef = new PageReference('/'); pageRef.setRedirect(true); return pageRef; } public class wrapAgent{ public User teleAgent {get; set;}//Please put the custom metadata names public Boolean selected {get; set;} //This is the contructor method. When we create a new object we pass a telesales metadata member that is set to the acc property. We also set the selected value to false public wrapAgent(User teleSalesAgent) { teleAgent = teleSalesAgent; selected = false; } } }and below is my test class:
@isTest public class Test_TodayTeleSalesDetails { public static testMethod void validateusersinqueue() { Group testGroup = new Group(Name='test group', Type='Queue'); insert testGroup; System.runAs(new User(Id=UserInfo.getUserId())) { QueuesObject testQueue = new QueueSObject(QueueID = testGroup.id, SObjectType = 'Lead'); insert testQueue; } Test.startTest(); TodayTelesalesDetails telesalesDetails=new TodayTelesalesDetails(); telesalesDetails.doFullSave(); telesalesDetails.doCancel(); Test.stopTest(); } }
I am not able to cover below lines of code:
for(User us : [select id from User where id =: userSetId]) { system.debug('message6>>'+us); for(Group gg : [select id,name from Group where type = 'Queue' and Name = 'TeleSales Queue']) { GroupMember gm = new GroupMember(); gm.groupId = gg.id; gm.UserOrGroupId = us.Id; gmm.add(gm); } }Below is the screenshot for the same:
My current code coverage stands at 73%
Many I request to help me on same to get a code coverage above 75%
Many thanks in advance
Thanks & Regards,
Harjeet
- Harjeet Singh 28
- August 19, 2019
- Like
- 1