Wednesday, 10 July 2019

Calling Specific Approval Process from Apex code


Use Below code in your condition and call particular approval process from Apex class or Trigger.

            Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
            req1.setComments('Submitting request for approval.');
            req1.setObjectId(lrr.Id);
           
            // Submit on behalf of a specific submitter
            req1.setSubmitterId(UserInfo.getUserId());
           
            // Submit the record to specific process and skip the criteria evaluation
            req1.setProcessDefinitionNameOrId('ApprovalprocessName');
            req1.setSkipEntryCriteria(true);
           
            // Submit the approval request for the account
            Approval.ProcessResult result = Approval.process(req1);

Thursday, 11 April 2019

Formatted Date Time In Salesforce Lighting



lightning:formattedDateTime component displays formatted date and time. This component uses the Intl.DateTimeFormat JavaScript object to format date values. The locale set in the app’s user preferences determines the formatting.
Below are the supported input values for lightning:formattedDateTimecomponent:
  • Date object
  • ISO8601 formatted string
  • Timestamp
Lightning Component:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!--Sample.cmp-->
<aura:component>
    <!--Declare Attribute-->
    <aura:attribute name="currentDate" type="Date"/>
     
    <!--Declare Handlers-->
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
     
    <!--Component Start-->
    <div class="slds-m-around_xx-large">
        <lightning:formattedDateTime aura:id="dt"
                                     value="{!v.currentDate}"
                                     month="short"
                                     day="numeric"
                                     year="numeric"
                                     hour="2-digit"
                                     minute="2-digit"
                                     second="2-digit"
                                     hour12="true"
                                     timeZone="{!$Locale.timezone}"/>
    </div>
    <!--Component End-->
</aura:component>
Lightning JS Controller:
1
2
3
4
5
6
({
    doInit : function(component, event, helper) {
        var today = new Date();
        component.set('v.currentDate', today);
    }
})
Output:
The above example will return a value in this “Feb 18, 2018, 10:37:13 AM” format.