Salesforce: Visualforce CommandButton to Bypass Validation/Required Fields

In Visualforce apex:CommandButton component, there is an attribute called “immediate” that allows us to invoke the controller action bypassing the validation rules associated with the fields (especially those that mark with required=”true”) in a visualforce page. I have been using this attribute alongside with the cancel button which does not required any input from users. Until recently, I noticed that the attribute no longer working as expected in one of my visualforce page development. For example:

<apex:page standardController="Account" extensions="AccountExt" standardStylesheets="true" applyBodyTag="false" docType="html-5.0" title="My Wizard">
	<apex:form id="theform" >
		<apex:pageBlockButtons >
			<apex:commandButton value="Cancel" action="{!cancel}" immediate="true"/>
			<apex:commandButton value="Search" action="{!doSearch}" />
		</apex:pageBlockButtons >
		
		<apex:pageBlockSection title="Test">
			<apex:inputfield value="{!account.Type__c}" required="true"/>
		</apex:pageBlockSection>
	</apex:form>
</apex:page>

After some research, I realised this is actually related to the behavior in HTML 5 (doctType=”html-5.0″) where it will automatically validate all the required fields that I have in a form. So, how can we overcome this?

Option 1 (Form level)

You can set an HTML 5 attribute called html-novalidate=”novalidate” at the form level. However, this will disable the validation for all buttons. You should only use this if you have your own validation logic implementation in the controller/extension class.

<apex:form id="theform" html-novalidate="novalidate" >

Option 2 (Button level)

You can have the similar attribute next to the command button to disable the validation on the button specifically.

<apex:commandButton value="Cancel" action="{!cancel}" immediate="true" html-formnovalidate="formnovalidate" />

This is a better option to go for as we do not need to worry about implementing the additional logic to validate the user input.

Triggering Salesforce Workflow/Process Builder when record is deleted

As of to date, Salesforce does not provide an object’s isDeleted flag as a filter criteria through workflow rule or process builder. This may lead to the option of utilising Apex Triggers if a requirement is to perform certain action when a record is deleted.

However, triggering a process builder/workflow is still possible when a record is deleted. Please consider the following criteria prior to designing your workflow or process builder in this case:-

  • the target object (to update field or to do something about it) is a parent to the deleted record
  • the target object and the deleted record is in master-detail relationship
  • the target object has capacity for additional roll-up summary field

Take Account-Opportunity for example. You may want to perform an action (i.e. update a field, send email alert, etc.) on the account where when one of its opportunity is deleted. As an alternative to utilise Apex Triggers, following are the steps that you may consider as a workaround to utilise Salesforce workflow/process builder instead:

  1. Create a roll-up summary field in account that counts the total opportunities which the account belongs to. In this example, we call it “Total_Opportunities__c”
  2. Define a workflow or process builder and utilise the evaluation criteria of “created, and every time it’s edited”
  3. Use the rule criteria of “Formula evaluates to true”
  4. Compile a formula which compares if the current “Total_Opportunities__c” is lower than the priorvalue. For example ${the_Roll_Up_Summary_Field} < PRIORVALUE(${the_Roll_Up_Summary_Field})
  5. Followed by the intended actions at the parent level

Wedid: Salesforce Skedulo Case Integration

Challenges

This companies main revenue source is derived from the repair services and additional products they provide to the commercial and residential business.

The technicians are required to repair items, keep track of replacement products issued to the customers, collect signatures, take images of the issues found, advise the next technician to onsite of the job requirements and what they foresee the next technician will be required to complete.

The challenge for this solution was that there would be up to 3 job visits, each job visit containing data that would need to be passed from one technician to another, without any phone or email communication.

Solution:

In the case, we used Apex trigger in conjunction with Skedulo and a custom Visualforce page to send the user to the Skedulo Web Browser for scheduling.

We used standard and custom fields created in Salesforce and Skedulo to capture some of the following data:

  • Products used
  • WHS issues identified or not
  • Signature Collected
  • Marketing Questions answered
  • Contact Details checked and updated
  • Images of site collected
  • Any expenses

There was a two-way sync with different trigger points between Skedulo and Salesforce allowing the data to flow back and forth.

Integrating the case with Skedulo enabled the client to automate communication between their field technicians and administration staff, reduce the paperwork created from each job, have a live status update running on each job/case for an enriched customer service and communication experience.

Related Objects Case, Skedulo Job, Product, Pricebook, Pricebook Entry
Components VisualForce, Trigger
Complexity Medium

Wedid: Custom CPQ

Challenges:

This company earns their revenues through providing services and lab products.

Currently, all the product details e.g selling prices, promo prices are stored in different external systems. These details are not available in Salesforce.

The sales team will need to manually check for product details – product prices from different systems before adding them into the Salesforce quote. This is causing a massive backlog in the quoting process and the company is looking for a solution to expedite the process.

For example:

  1. User is going to propose Product A.
  2. The user logs in to system A to check for the selling price for Product A.
  3. Then, the user logs in to system B to check for the promo price (if any) for Product A.
  4. Once confirmed, the user includes Product A as line item in the quote.

Solution:

  1. Create a custom page in Salesforce that allows user to search for the products.
  2. Using integration and web service calls, allow user to search for the prices of the selected products from both systems through the same custom page in Salesforce.
  3. From the price search results, user can proceed by creating a quote and and quote line items.
Related Objects Product, Pricebook, Pricebook Entry, Opportunity, Opportunity Product, Quote, Quote Line Item
Components/App VisualForce, Trigger

Web Service Calls base code generated via WSDL2Apex then further modified to suit the need.

Complexity Difficult

Challenge encountered as the initial WSDL file was not compliant with WSDL2Apex requirement and necessitated adjustment before it can be parsed by WSDL2Apex.

 

WEDID: Boomi Advanced User Security

Challenges

Customer has the requirement to restrict Boomi login users to have certain privileges when performing development and/or monitoring the processes logs. For example, a developer should not be given privilege to see production logs but he/she is allow to at least perform development as well as viewing logs/data processes deployed in a non-production environment.

Solution:

Purpose Create more restrictive privileges for different Boomi login users of an account.
Applications Dell Boomi Atomsphere
Tool Dell Boomi Atomsphere
Information Enable the Boomi Advanced User Security feature. This allows creation of custom roles with combination of different privileges. Assign the different custom roles setup to the appropriate user as well as assigning the respective custom roles to only the environment which the user is allow to see.
Complexity Low

Boomi: Handling Additional Parameters when extending OAuth 2 details

Boomi allows extending OAuth 2 details for example in a HTTP Client Connector.

http_extension

When defining the connection details in the development mode, you are allow to build the Authorization and Access Token URL with additional parameters via the “Add Authorization Parameter” and “Add Access Token Parameter” section:

additional_params

There is no way to extend the additional parameters portion as of today.

An alternative approach is to consider building the parameters directly through the “Authorization Token URL” and “Access Token URL” directly instead.

For example: ${the_authorization_url}?response_type=code&resource=……

In this case, you can then overwrite the parameters through the “OAuth2 Authorization Token URL” and “OAuth2 Access Token URL” in the extension.

This is something to be considered when you are planning to extend the OAuth 2 details for a connector.

Wedid: Custom Lead Convert on Related Lists

Challenges:

There are additional information being tracked by the user under leads. These information are stored in custom objects linked against the leads (the lead related list). These additional information are required to be brought over on lead conversion however,  Salesforce out-of-the-box does not convert custom related list.

Sample scenario:

There are booking records created against a lead. When the lead is converted, user will need to see these booking records under the converted record (Person account).

Solution:

  1. Create lookup fields on the custom object. Lookup fields will be against the lead and against the converted object. In the scenario above apart from the lead lookup, create a lookup to contact.
  2. Build a simple trigger to populate the contact Id into the contact lookup field when the lead is converted OR
  3. Utilize the process builder that does the same as the trigger above
Related Objects Custom object(s)
Components/App Trigger OR Salesforce Process Builder
Complexity Easy

Need your Salesforce Inventory linked to Xero or Saasu?

Want to load data from Xero or Saasu?

We’ve added more functionality to our highly successful product, RIO Readymade Inventory Plus. You can now transfer data from Xero or Saasu to RIO Readymade Inventory Plus.

Can I use other csv data files?

Yes! The program can also handle any csv file in the required format.

How does it work?

  1. Send us an email at support@wdcigroup.net and we’ll send you the job.
  2. The upsert uses Skyvva data loader. Skyvva can be downloaded for free.
  3. Install Skyvva (this app is available on Appexchange).
  4. Install our job
  5. Download the data from Xero/Saasu
  6. Follow the instructions to upload your data to Salesforce.

What if I need some help?

Videos and documentation are available here.

Build on Salesforce features. Can I automate it?

Subscribe to Skyvva and you can email the data to automate the process

Salesforce: Lookup Filter for Different Record Type

Scenario: How to limit a lookup field to only show certain records based on record type. For example, account has 2 record type – HQ & Branch. Each branch will need to specify the HQ using the Parent Account field:

HQ (Parent Account)
Branch 1
Branch 2
Branch 3

Based on the example above, we need to apply below restriction:

  • A Branch account can not have another branch account as parent.
  • A HQ account can not have branch as parent acount.

Solution #1: Lookup filter (Recommended)

You can use lookup filter to limit the selection based on record type. For example:

Filter criteria:
  1. Account record type = Branch
  2. Parent account record type = HQ
  3. Account record type = HQ
  4. Parent account record type = HQ
Filter logic:
(1 AND 2) OR (3 AND 4)Note!: Make sure that filter type is set to Required to make sure that the lookup value MUST match criteria!

Solution #2: Validation

You can also choose to create a set of validation rule to stop user upon saving a record. For example:

OR(
AND(RecordType = Branch, NOT(ParentAccount.RecordType = HQ)),
AND(RecordType = HQ, NOT(ParentAccount.RecordType = HQ))
)

Both solution above will trigger on bulk insert/update. You will probably get below error when you try to assign parent account that doesnt fit the criteria:

  1. ERROR: Value does not exist or does not match filter criteria  OR
  2. The error message you set in the validation rule

Form Assembly: Email Notification

Question:

  1. How to setup email notification?
  2. How to customise it?
  3. If an attachment is submitted in a form, how to display the attachment in the email notification?

Question #1: How to setup email notification?
Solution:

  1. Login to Form Assembly > Click on Form
  2. Go to the Notification tab on right panel
  3. Under ‘Your Notifications’ section, choose Enabled (text emai) to send text notification email or Enabled (HTML email) where the email content will be in HTML form.

Question #1: How to customise it?
If you would like to customise the email notification content, you can do so by selecting ‘Customized template’ under Email template selection after enabling email notification.

Note: You can play around with different aliases to display different information in email notification. For example, use %%RESPONSE%% to display all submitted data in the form. Do bear in mine that hidden fields will also be displayed in the email notification.

Question 3: If an attachment is submitted in a form, how to display the attachment in the email notification?
If your form allows attachment and the receipient would like to view the attachment in the email notification, you can do so by using below aliases:

  1. %%FILE_LIST%% = Displays URL link that directs to attachment record stored in Form Assembly. Login is required in order to view/download the file.
  2. %%UNPROTECTED_FILE_LIST%% = Automatically downloads file when the url link is clicked. Login is not required.