Sunday, September 30, 2018

How to Show Instructions to the User in Lightning Component

this Post Explains the How to Show the Instructions to User in Lightning Component
Using <ui:message /> Lighting tag We can Show The Different Severity to the user.
severity="confirm"
severity="info"
severity="warning"
severity="error"
Based on Your Requirement You Can Use the Severity
I used severity="info", For Showing the Instructions to The User.
Check Below Code For Reference

<ui:message severity="info" closable="false">
            <h1 style="color:red;">Instructions:</h1>
            <p>                
                <li>Please Enter Valid <b style="color:#5041f4">Opportunity Name and Close Date</b> to Search.</li>
                <li>If you want to create New Opportunity Click on <b style="color:#5041f4">New</b> button.</li>
                <li>If you want to Delete Mulitiple Records in a table. Please Select the Check boxs
                    for that record after that click on Delete Selected Button.</li>
                <li>If you Want to Perform Row Action, Please Click On <b style="color:#5041f4">Down arrow on Table Row to Perform Row Actios(Edit, Delete,View).</b></li>
            </p>
</ui:message>

Screen Shot

Let Us Know If You have any queries.
Happy Learning!!

Wednesday, September 26, 2018

How to Check Your Org Governor Limits Using Workbench

If you Need to Check The Your Org Total Governor Limits
Follow Below Steps

  • Login to Workbench
  • Select Production/Sandbox(Based On your Preferences)
  • Give your Login Credentials and Give Allow Access To Workbench
  •  On the Jump to picklist select "REST Explorer"
  • Click "Select"
  • From the options presented select:  /services/data/vXX.0/limits
  • Click "Execute"
EX: /services/data/v43.0/limits

Demo:

When clicking on the link, it will open the Page looks like below image

Once you login to the Salesforce
Select "REST Explorer" From Jump List
Click on Select
Select "Get" Method and Click On Execute Button
Result Will LOOK Like this


Let us know If you have any queries.
Happy Learning!

Monday, September 24, 2018

How to Redirect to URL Based on Theme and Site Name in Salesforce

If you are Redirecting URL From Button and That Button Used In Different Places Like Community, Partner Portal, Lightning Experience.
In Lightning Experience, URL is Different Compare to the Classic Theme URL.
So First You Need to check the Current User Theme Based On Theme You Need to Redirect to The URL.
Check Bellow themes are available in Salesforce.

Theme1 —> Obsolete Salesforce theme
Theme2 —> Salesforce Classic 2005 user interface theme
Theme3 —> Salesforce Classic 2010 user interface theme
Theme4d —> Modern “Lightning Experience” Salesforce theme
Theme4t —> Salesforce1 mobile Salesforce theme
PortalDefault —> Salesforce Customer Portal theme
Webstore —> Salesforce AppExchange theme

To Check the Current theme in Visualforce page use below Global Variables

{!$User.UIThemeDisplayed}
OR
In Apex UserInfo.getUiThemeDisplayed().
To Check Site Name in Visualforce Page Use Global Variable
{!Site.Name}
In Portal or Communities URL is Different like
https://Baseurl/<portalName>/apex/apexpage/
Demo:
Check Below VisualForce Page to understand easily
<apex:page standardController="Account" showHeader="false" sidebar="false">
    <script>   
     if(typeof sforce !== 'undefined' && sforce !== null && '{!$User.UIThemeDisplayed}' === 'Theme4d') {
         window.open('/apex/ApexTestPage?id={!Account.Id}');
         sforce.one.back(true);
     }
     else if('{!$User.UIThemeDisplayed}' !== 'Theme4d' && ('{!$Site.Name}' == undefined || '{!$Site.Name}'  == '' || '{!$Site.Name}'  == null)) {
        window.open('/apex/ApexTestPage?id={!Account.Id}','_blank');
        window.top.location = '/{!Account.Id}';
     }
     else if('{!$Site.Name}' != null || ('{!$User.UIThemeDisplayed}' === 'Theme4d' && '{!$Site.Name}' != null)) {
         var siteName = '{!$Site.Name}';
         siteName = siteName.toLowerCase(); 
         window.open('/'+siteName+'/apex/ApexTestPage?id={!Account.Id}','_blank');
         window.top.location = '/'+siteName+'/{!Account.Id}';
     }
    </script>
</apex:page>

for Testing, Create Detail Page Button on Account(I Used Standard Controller as Account), Based on Your Preference create button and add the Page.
After that Add Button in Layouts based on your Preferences Like(Community, Portal, Lightning Experience).

Note: You can change the Script in Visualforce Page based on Your Requirement and you Can Extend the Functionality Further.

References:
Site Reference In Visualforce Page
sforce Methods
Let us know if you have any queries.

Happy Learning!!!

Friday, September 7, 2018

Calculate Total Sum of Column in PageBlockTable In Visualforce Using Jquery

Some Particular Scenarios we need to Calculate the total sum value Based on User Enter Values in Text Boxes in PageBlockTable.

Recently I Faced this Scenario We can Resolve The Scenario By Using JavaScript or Jquery.
This Code work on input Event, You can Use any Event Based on Your Requirement(onchange, onblur, onfocus etc).


<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script>
        $(document).ready(function () {
         $(document).on("input", ".pricevalue", function (e) {
            var sum = 0;
            $('.pricevalue').each(function(){
                var num = $(this).val();
                if(num != 0 && !isNaN(num)) {
                    sum += parseFloat(num);
                }
            });
            $(".outputPrice").text(sum.toFixed(2));
        });
    });
    </script>
And This Is the Column Code in PageBlockTable
<apex:column headerValue="Unit Price">
  <apex:inputText value="{!wd.dUnitPrice}" styleClass="pricevalue" id="unitpric" />
  <apex:facet name="footer">
    <apex:outputText id="totalPrice" value="{!dSumValue}" styleClass="outputPrice" />
  </apex:facet> 
</apex:column>

Check Screenshot For More information
Let us know if you have any queries.
Happy Learning!