• @GM
  • NEWBIE
  • 134 Points
  • Member since 2013
  • Salesforce Developer/Admin/Consultant

  • Chatter
    Feed
  • 2
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 41
    Questions
  • 101
    Replies
Hi,

I am trying to create a time dependent workflow action to send an email to the creator after one hour if the status remains "In progress"
I see the entry in the monitoring queue but nothing is happening after the "Scheduled Date"

WF evaluation criteria is "Created"

Thanks,
Krishna.
Hi,

We have a need to call a queueable apex class from a trigger after insert. Would it be possible to do the following below as we need to also do chaining? We need to perform updates to different objects in consecutive order so wanted to use a queue. 
trigger SomeTrigger on CustomObject__c (after insert) {
       System.enqueuejob(new  QueueClass1(Trigger.new))
}

public class QueueClass1 implements Queueable {
              private List<CustomOBject__c> objs;
              
              public QueueClass1(List<CustomObject> recs) {
                            this.objs = recs;
              }
              
               public void execute(QueueableContext queCont) {
                            //execute some logic on objs list
                            //perform update

                          //call second queueable apex job
                         System.enqueueJob(new QueueClass2(recs));
               }

}

public class QueueClass2 implements Queueable {
              private List<CustomOBject__c> objs;
              
              public QueueClass2(List<CustomObject> recs) {
                            this.objs = recs;
              }
              
               public void execute(QueueableContext queCont) {
                            //execute other logic on objs list
                            //create records for another objects
                            List<Account> acnts; //acnts list is populated based on logic executed in the "other logic"
                             insert acnts;
               }

}

 
  • April 03, 2017
  • Like
  • 0
Hi All,

when I'm trying to call application event then I'm getting below error and $A.get(event) is returning undefined which is marked bold in the below code.
Error : Uncaught TypeError: Cannot read property 'setParams' of undefined
 
CalendarView.cmp  :

<aura:component controller="CalendarController" implements="force:hasRecordId,force:hasSObjectName,force:appHostable" access="global">
<aura:registerEvent name="loadMyEvent" type="harshabr:ResultEvent"/>
    
    <ltng:require styles="/resource/gpcal_lex_yo_SLDS0121/assets/styles/salesforce-lightning-design-system-ltng.css,/resource/gpcal_lex_yo_fullcalendar/fullcalendar-2.6.0/fullcalendar.css" 
	scripts="/resource/gpcal_lex_yo_jquery,/resource/gpcal_lex_yo_fullcalendar/fullcalendar-2.6.0/lib/moment.min.js,/resource/gpcal_lex_yo_fullcalendar/fullcalendar-2.6.0/fullcalendar.js"
              
	afterScriptsLoaded="{!c.doInit}"
/>
	<aura:attribute name="recordId" type="String" access="global"/>
	<aura:attribute name="sObjectName" type="String" access="global"/>	
	<aura:attribute name="user_id" type="String" />
    
    <aura:attribute name="cal" type="Boolean" default="true" />
	<aura:attribute name="evtRec" type="List" />
    <aura:attribute name="eventId" type="String" />
    
     <aura:renderIf isTrue="{!v.cal}">
        <div id='calendar'>
        <!-- <c:EventsList evtId="{!v.eventId}" /> -->
	</div>
    </aura:renderIf>    
      
</aura:component>

CalendarViewController :

({
	doInit: function(component, event, helper){
        $('#calendar').fullCalendar({
	    	defaultView: 'month',
	    	allDaySlot: false,
	    	selectable: true,
			selectHelper: true,
			select: function(start, end) {
				
				var title = prompt("Please enter subject of event:");
				var eventData;
				if (title) {

					var action = component.get("c.createNewEvent");
					var params = { 
						start_time : start.format("YYYY-MM-DD HH:mm:ss"),
						end_time   : end.format("YYYY-MM-DD HH:mm:ss"),
						user_id    : component.get("v.user_id"),
						what_id    : component.get("v.recordId"),
						sobjectName    : component.get("v.sObjectName"),
						title      : title		
					};
					action.setParams(params);

					action.setCallback(this, function(actionResult) {				        				        
				        if( actionResult.getReturnValue() ){
				        	$('#calendar').fullCalendar( 'refetchEvents' );
				        	console.log("save successful");
				        }
				        else{

				        	alert( "Save failed for some reason." );
				        }
				    });
				    
				    $A.run(function(){
				    	$A.enqueueAction(action);						
				    });

				    

				}
				$('#calendar').fullCalendar('unselect');
			},
	    	events: function(start, end, timezone, callback) {
	    		var user_id = component.get("v.user_id");	    		
				var action = component.get("c.getEvents");
				action.setParams(
					{ 
						start_time : start,
						end_time   : end,
						user_id    : user_id		
					}
				);

				action.setCallback(this, function(actionResult) {
			        callback(JSON.parse(actionResult.getReturnValue()));
			    });
			    $A.enqueueAction(action);				
	    	},
            eventClick: function(calEvent, jsEvent, view) {
    	        console.log('gm calEvent '+calEvent);
                console.log('gm1 '+calEvent.id);
                var evtId = calEvent.id;
                component.set("v.cal",true);
                var evt = $A.get("e.c:ResultEvent");
            	console.log(evt);
                console.log(evtId);
				evt.setParams({ "pass_result": evtId });
				evt.fire();
                
		    }
	    });
	}
})


ResultEvent.evt :
<aura:event type="APPLICATION">
    <aura:attribute name="pass_result" type="String"/>
</aura:event>

app:

<aura:application extends="force:slds">
    <c:CalendarView />
    <c:EventsList />
</aura:application>


EventsList.cmp :
<aura:component controller="CalendarController" access="global">
  <aura:attribute name="eventData" type="List" access="global" />
    <aura:handler event="harshabr:ResultEvent" action="{!c.getMyEvents}" />
    
    <table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer slds-table--fixed-layout">
    <thead>
      <tr class="slds-text-heading--label">
        <th scope="col"><div class="slds-truncate" title="ID">ID</div></th>
        <th scope="col"><div class="slds-truncate" title="Subject">Subject</div></th>
        <th scope="col"><div class="slds-truncate" title="StartDateTime">StartDateTime</div></th>
      </tr>
    </thead>
    <tbody>
      <!-- Use the Apex model and controller to fetch server side data -->
      <aura:iteration items="{!v.eventData}" var="e">
        <tr>
          <th scope="row"><div class="slds-truncate" title="{!e.Id}">{!e.Id}</div></th>
          <td><div class="slds-truncate" title="{!e.Subject}">{!e.Subject}</div></td>
          <td><div class="slds-truncate" title="{!e.StartDateTime}">{!e.StartDateTime}</div></td>
          <td>
            <form class="account-form" onsubmit="{!c.deleteAccount}">
              <input type="hidden" value="{!e.Name}" class="account-name" />
             
               <!--  Use a Lightning Base Component
                To display an icon next to the label-->
             
              <lightning:button label="Delete"
                                iconName="utility:delete"
                                iconPosition="left"
                                variant="destructive"
                                />
            </form>
          </td> 
        </tr>
      </aura:iteration>
    </tbody>
  </table>
</aura:component>

 EventsListController :
({
getMyEvents: function(component, event, helper){
        var action = component.get('c.getEventss');
    	var evtIds = event.getParam("pass_result");
      	console.log('GM evtId '+evtIds);
      	action.setParams({
        	  "eventId": evtIds
      	});
    	// Set up the callback
    	var self = this;
    	action.setCallback(this, function(actionResult) {
     		component.set('v.eventData', actionResult.getReturnValue());
    	});
      	console.log("GM res "+component.get('v.eventData'));
    	$A.enqueueAction(action);
    },
  deleteAccount: function(component, event, helper) {
    // Prevent the form from getting submitted
    event.preventDefault();

    // Get the value from the field that's in the form
    var accountName = event.target.getElementsByClassName('account-name')[0].value;
    confirm('Delete the ' + accountName + ' account? (don’t worry, this won’t actually work!)');
  }
})
  • February 06, 2018
  • Like
  • 1
There is custom button created (it redirects to VF on click of it) & placed on standard opportunity page layout.
 There is inline VF page present on same standard opportunity page layout.
 
Is it possible to control the appearance of this custom button (Show/Hide) based on the some fields value of opportunity records via JS or any approach without creating multiple page layouts or overriding std opportunity page layout with Vf page?
 
I looked into some of blogs but those solution will work only for the buttons present inside inline VF page or on overriding std page layouts
Ex : http://blogatsalesforce.blogspot.in/2015/04/enable-disable-buttons-on-standard.html
 
 
  • April 29, 2017
  • Like
  • 0
The below code is not covering both RequestClass & ResponseClass. Any help?

Test Class:

@isTest
public class OpportunityDataResourceTest {
private static testMethod void doGetTest_Positive(){
           Opportunity o = BacklogGeneratorTestFactory.InsertOpportunity(Date.newInstance(2015,01,01), 2, true, 100);
        o = [SELECT Id,Services_Provided__c,StageName,
                          Signed_SOW__c,Job_Setup__c,
                          Expected_SOW_Signed_Date__c,
                          Billing_Type__c,
                          Business_Developer__c,
                          Ultimate_Client__c,
                          Engagement_Name1__c,AccountId
                            FROM Opportunity WHERE Id = :o.Id];
        
        Test.startTest();
        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();
        
        req.requestURI = '/services/apexrest/fetchOpportunities';  //Request URL
        req.httpMethod = 'POST';//HTTP Request Type
        
        OpportunityDataResource.RequestClass reqParam = new OpportunityDataResource.RequestClass();
        reqParam.opportunityId = String.valueOf(o.Id);
        String JsonMsg=JSON.serialize(reqParam);
        req.requestBody = Blob.valueof(JsonMsg);
        RestContext.request = req;
           RestContext.response= res;
        OpportunityDataResource.ResponseClass response = OpportunityDataResource.doGet(reqParam);
        Test.stopTest();
        system.assertEquals(true, response.isValid);
        system.debug('obj status '+response);
    }
}



Class :

@RestResource(urlMapping='/fetchOpportunities/')
global with sharing class OpportunityDataResource {
    //request parameters from external system
    global class RequestClass{
        webservice String opportunityId;
    }
    
    //response class to send it to external system
    global class ResponseClass{
        webservice String serviceCode;
        webservice String description;
        webservice Boolean isValid;
        //webservice List<Opportunity> lstOpptyToBeReturn;
    }
    
      @HttpPost
    global static ResponseClass doGet(RequestClass req){
        
        ResponseClass response = new ResponseClass();
        List<Opportunity> lstOpp = new List<Opportunity>();
        try{
            //get the opptyId from request class
              String opptyId = String.escapeSingleQuotes(req.opportunityId);
            if(opptyId!=null && String.isNotBlank(opptyId.trim())){
                lstOpp = [Select Id,Name from Opportunity where Oppty_ID_For_Elite__c =: opptyId];
            }
            //form the response if the list of opportunites are found in the system
            if(!lstOpp.isEmpty() && lstOpp.Size() == 1){
                response.isValid = true;
                response.serviceCode = 'Success-1';
                response.description = lstOpp.size()+' '+'opportunities found with Id - '+opptyId;
                return response;
            }
            //form the response if the list of opportunites are found in the system
            else if(lstOpp.isEmpty()){
                response.isValid = false;
                response.serviceCode = 'Error-1';
                response.description = 'No opportunity found with Id - '+opptyId;
                return response;
            }
            //form the response if the list of opportunites are not found with list error
            else{
                response.isValid = false;
                response.serviceCode = 'Error-2';
                response.description = 'No opportunity found.Please Contact salesforce system admin';
                return response;
            }
        }
        //exception handling for SOQL query
        Catch(System.QueryException e){
            response.serviceCode = 'Error-1';
            response.description = 'Query exception : '+e+' found.Please Contact system admin';
            return response;
        }
        //exception handling other than SOQL
        Catch(Exception e){
          response.serviceCode = 'Error-2';
            response.description = 'Exception : '+e+' occured.Please Contact system admin';
            return response;  
        }        
    }
}
  • March 10, 2017
  • Like
  • 0
On creation or after creating a new opportunity, I need to add multiple opportunity records to this newly created opportunity.
How can this be accomplished?

I have refered the below link but it wont satisfy the above requirement.
https://help.salesforce.com/articleView?id=000004368&type=1

Regards,
GM.
  • February 20, 2017
  • Like
  • 0
Error occurred trying to load the template for sending preview email: DML currently not allowed. 


I'm getting above error even after adding allowDML="true" to component.

Could any one help on this?


VF template :


<messaging:emailTemplate subject="Alert: WON Opportunity -" recipientType="User" relatedToType="Opportunity">

      <messaging:htmlEmailBody >

      <c:opportunityAttachedFiles componentValue="{!relatedTo.Id}"/>

      </messaging:htmlEmailBody>

</messaging:emailTemplate>


VF Component :


<apex:component controller="OpportunityAttachments" allowDML="true" access="global">

    <apex:attribute name="componentValue" description="Attribute on the component."
                  type="Id" required="required" assignTo="{!opptyId}"/>
    <apex:dataTable value="{!OpptyFilesLink}" var="att">
        <apex:column >
            <apex:facet name="header">File Name</apex:facet>
            {!att.Name}
        </apex:column>
        <apex:column >
            <apex:facet name="header">File Link</apex:facet>
            {!att.DistributionPublicUrl}
        </apex:column>
    </apex:dataTable>
</apex:component>


Controller :


public class OpportunityAttachments {
    public Id opptyId;
    
    public void setopptyId (Id oppId) {
        opptyId = oppId;
    }
    
    public String getopptyId() {
        return opptyId;
    }
    
    public List<ContentDistribution> getOpptyFilesLink(){
        List<ContentDistribution> lstTobeInserted = new List<ContentDistribution>();
        List<ContentDistribution> lstToReturn = new List<ContentDistribution>();
        Set<Id> setContentDocumentId = new Set<Id>();
        List<ContentDocumentLink> lstContentDocumentLink = new List<ContentDocumentLink>();
        if(String.ValueOf(opptyId) != null && String.ValueOf(opptyId) != ''){
            lstContentDocumentLink = [SELECT ContentDocumentId,Id,IsDeleted,LinkedEntityId,ShareType,SystemModstamp,Visibility FROM ContentDocumentLink where LinkedEntityId =: opptyId];
        }
        if(!lstContentDocumentLink.isEmpty()){
            for(ContentDocumentLink obj : lstContentDocumentLink){
                setContentDocumentId.add(obj.ContentDocumentId);
            }
            
            for(ContentDocument obj :[SELECT ArchivedById,ArchivedDate,ContentModifiedDate,ContentSize,CreatedById,CreatedDate,Description,FileExtension,FileType,Id,IsArchived,IsDeleted,LastModifiedById,LastModifiedDate,LastReferencedDate,LastViewedDate,LatestPublishedVersionId,OwnerId,ParentId,PublishStatus,SharingOption,SystemModstamp,Title FROM ContentDocument where Id=: setContentDocumentId]){
                ContentDistribution cd = new ContentDistribution();
                //cd.ContentDocumentId = obj.ContentDocumentId;
                cd.name = obj.Title;
                cd.ContentVersionId = obj.LatestPublishedVersionId;
                cd.PreferencesAllowOriginalDownload = false;
                cd.PreferencesAllowPDFDownload = false;
                cd.PreferencesAllowViewInBrowser = true;
                lstTobeInserted.add(cd);
            }
            Database.upsert(lstTobeInserted,ContentDistribution.Name.getDescribe().getSObjectField(),false);
        }
        set<Id> getLatest = new set<Id>();
        for(ContentDistribution obj : [Select ContentDocumentId,Name,ContentVersionId,DistributionPublicUrl from ContentDistribution order by CreatedDate DESC]){     
            if(!getLatest.contains(obj.ContentDocumentId)){
                getLatest.add(obj.ContentDocumentId);
                lstToReturn.add(obj);
            }
        }
        return lstToReturn;
    }
}


Thanks,

GM
  • February 10, 2017
  • Like
  • 0
Hi All,
 
I'm trying to hit POST service but getting Internal Server Error (System.HttpResponse[Status=Internal Server Error, StatusCode=500]).
 
Have added the end point host URL to remote site setting. The SOUP UI tool able to hit service without any problem
 
Code:
 
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
req.setHeader('Content-Type','application/x-www-form-urlencoded');
req.setEndpoint('http://www.webservicex.net/globalweather.asmx/GetCitiesByCountry');
req.setMethod('POST');
//req.setBody('CountryName='+EncodingUtil.urlEncode('india', 'UTF-8'));
req.setBody('CountryName=india');
req.setCompressed(true); // otherwise we hit a limit of 32000
try {
    res = http.send(req);
    System.debug(res.toString());
} catch(System.CalloutException e) {
    System.debug('Callout error: '+ e);
    System.debug(res.toString());
}
 
Thanks,
GM.
  • October 17, 2016
  • Like
  • 0
Hi All,

I have created conneted app in one of our SFDC sandbox and tring to get the token but ended up with below error.
Please suggest.

Follewd the below link :
https://help.salesforce.com/HTViewHelpDoc?id=remoteaccess_oauth_jwt_flow.htm#create_token


Error : java.security.InvalidKeyException: No installed provider supports this key: (null)
    at java.security.Signature$Delegate.chooseProvider(Unknown Source)
    at java.security.Signature$Delegate.engineInitSign(Unknown Source)
    at java.security.Signature.initSign(Unknown Source)
    at JWTExample.main(JWTExample.java:45)


JAVA Class  code :
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.BaseNCodec;
import java.io.*;
import java.security.*;
import java.text.MessageFormat;  

public class JWTExample {

  public static void main(String[] args) {

    String header = "{\"alg\":\"RS256\"}";
    String claimTemplate = "'{'\"iss\": \"{0}\", \"sub\": \"{1}\", \"aud\": \"{2}\", \"exp\": \"{3}\"'}'";

    try {
      StringBuffer token = new StringBuffer();

      //Encode the JWT Header and add it to our string to sign
      token.append(Base64.encodeBase64URLSafeString(header.getBytes("UTF-8")));

      //Separate with a period
      token.append(".");

      //Create the JWT Claims Object
      String[] claimArray = new String[4];
      claimArray[0] = "client_id";
      claimArray[1] = "username";
      claimArray[2] = "https://test.salesforce.com";
      claimArray[3] = Long.toString( ( System.currentTimeMillis()/1000 ) + 300);
      MessageFormat claims;
      claims = new MessageFormat(claimTemplate);
      String payload = claims.format(claimArray);

      //Add the encoded claims object
      token.append(Base64.encodeBase64URLSafeString(payload.getBytes("UTF-8")));

      //Load the private key from a keystore
      KeyStore keystore = KeyStore.getInstance("JKS");
      keystore.load(new FileInputStream("C:/Users/gm/Downloads/Backup/00DQ000000GKQwv.jks"), "password1".toCharArray());
      PrivateKey privateKey = (PrivateKey) keystore.getKey("00DQ000000GKQwv.jks", "password1".toCharArray());

      //Sign the JWT Header + "." + JWT Claims Object
      //Signature signature = Signature.getInstance("SHA256withRSA");
      Signature signature = Signature.getInstance("SHA256withRSA");
      
      signature.initSign(privateKey);
      signature.update(token.toString().getBytes("UTF-8"));
      String signedPayload = Base64.encodeBase64URLSafeString(signature.sign());

      //Separate with a period
      token.append(".");

      //Add the encoded signature
      token.append(signedPayload);

      System.out.println(token.toString());

    } catch (Exception e) {
        e.printStackTrace();
    }
  }
}


Thanks,
GM
  • May 06, 2016
  • Like
  • 0
The scheduler is calling a batch apex which will do upsert on Object1.
The trigger (after insert and after update event) written on Object1 will get execute and it will call another batch apex and it will do upsert on Object2.
The trigger (after insert and after update event) written on Object2 will get execute and it will call another batch apex and it will update Object3 [No trigger on this object ].

If all these 3 batch execute in sequentially then there is no problem but it’s not guaranteed as bez resources will not be available every time from the salesforce hence often I'll get below error for some records

Error : System.AsyncException Database.executeBatch cannot be called from a batch start, batch execute, or future method

Could you please let me know how to avoid this?

Thank you.

Regards,

GM
  • March 11, 2015
  • Like
  • 0
I have to display this tr only when there is a value in EOL_Info__c field in VF TEmplate

but for the following code i'm getting sytax error and if i remove (!) before IF then it will get save but wont work.

<tr style="display: {!IF((ISBLANK({!relatedTo.PRM_EOL_Info__c})), 'none', 'table-row')};">
                    <td>EOL Info:</td>
                    <td>{!relatedTo.EOL_Info__c}</td>
</tr>

Please suggest some solution

Thanks in advance

Regards,
GM
  • February 11, 2015
  • Like
  • 0
Hi All,

I have configured workflow to send email using VF email template.

If i click the button Send Test and Verify Merge Fields, then values are coming in all merge fields.

But when that workflow(send email using VF email template) get executed then the two merge fields are not coming with values (Dear Field_value1 and Field_value2,).

The class is having signature Without sharing.

Could you please suggest to resolve this issue?

Thanks in Anticipation,

Regards,
GM ...
  • January 30, 2015
  • Like
  • 0
In the below code the value of {!relatedTo.PRM_EOL_Reason__c} this field(which is picklist) is not coming in the vf email template

Could you please help that how to display this in the email template?

<messaging:emailTemplate subject="Notification for EOL" recipientType="User" relatedToType="Lead">
<messaging:htmlEmailBody >
    <html>
        <body>
            <p><b>Dear {!relatedTo.Assigned_ESR__r.Name} and {!relatedTo.Assigned_CAM__r.Name},</b><br/>

             The following partner accepted lead has been EOL’d with reason code: {!relatedTo.PRM_EOL_Reason__c}
         
             <br/>
            Please contact the partner user if you need additional info as to why this lead was EOL’d (End of Lifed).</p>
            <br/>
              
            <p><b>Lead Information:</b><br/>
            Lead Number: {!relatedTo.PRM_Lead_Number__c}<br/>
            Lead Assigned Date:&nbsp;  <apex:outputText value="{0,date,MMM dd','yyyy}">
            <apex:param value="{!relatedTo.Partner_Assigned_Date__c}" /></apex:outputText><br/>
           
            
            
            <p>Regards</p>
            
            <p>Admin</p>
           

        </body>
    </html>
 
</messaging:htmlEmailBody>

</messaging:emailTemplate>
  • January 27, 2015
  • Like
  • 0
this is header which will appear before Scrolling.This is the screenshot of header after scrolling

Please Observe the space between DRI and BOM columns in the both images....
Please suggest solution to get proper format for header using CSS.

Thank you.
  • September 22, 2014
  • Like
  • 0
Please Suggest,

Here Class__c is Parent
and Student__c is Child 
Child Relationship Name is Students,

Map<Id,List<Student__c>> mapName=new Map<Id,List<Student__c>>([Select Id,(select Name from Students__r) from Class__c]);

Query is working fine in developer console but in apex class, getting error for the above statement.

Regards,
GM
  • August 18, 2014
  • Like
  • 0
When "Submit for Approval", sometimes Message appeared. We cant understand why Unable to Submit with just message? So, need to output which condition Invalided.
How to format this error to show it to end user.

For example when a record has been submitted for approval,
The approver has to provide a value to one field which will be required field for trigger.
If the approver approved the record without providing a value to that field then he will get a error message.
Instead of this i want to pop up a msg or display the error in a better way so that approver can understand.

Pla provide best approch to achieve this.

Thank you.

Regards,
GM
  • August 13, 2014
  • Like
  • 0
How to cover following bold lines in test class


for(String field: fields) {
                System.debug('field'+field);
                if (field.startsWith('"') && field.endsWith('"')) {
                    cleanFields.add(field.replaceAll('DBLQT','"'));
                } else if (field.startsWith('"')) {
                    makeCompositeField = true;
                    compositeField = field;
                    System.debug('compositeField');
                } else if (field.endsWith('"')) {
                    compositeField += ',' + field;
                    cleanFields.add(compositeField.replaceAll('DBLQT','"'));
                    makeCompositeField = false;
                } else if (makeCompositeField) {
                    compositeField +=  ',' + field;

                } else {
                    cleanFields.add(field.replaceAll('DBLQT','"'));
                }
            }


test Class:
this is the data passing to csv parsing,
string csvContent = 'Number,Name\n12345,test';
  • July 29, 2014
  • Like
  • 0
can we create filter by status updates.to create custom filters / Most Popular, Most Recent, etc.
  • June 10, 2014
  • Like
  • 0
can we create filter by status updates.to create custom filters / Most Popular, Most Recent, etc.
  • June 06, 2014
  • Like
  • 0
Is it possible to do this in salesforce?


Ability to tweet via Community
Retweet questions and answers to my Twitter handle.

Regards,
GM
  • June 06, 2014
  • Like
  • 0
Hi All,

when I'm trying to call application event then I'm getting below error and $A.get(event) is returning undefined which is marked bold in the below code.
Error : Uncaught TypeError: Cannot read property 'setParams' of undefined
 
CalendarView.cmp  :

<aura:component controller="CalendarController" implements="force:hasRecordId,force:hasSObjectName,force:appHostable" access="global">
<aura:registerEvent name="loadMyEvent" type="harshabr:ResultEvent"/>
    
    <ltng:require styles="/resource/gpcal_lex_yo_SLDS0121/assets/styles/salesforce-lightning-design-system-ltng.css,/resource/gpcal_lex_yo_fullcalendar/fullcalendar-2.6.0/fullcalendar.css" 
	scripts="/resource/gpcal_lex_yo_jquery,/resource/gpcal_lex_yo_fullcalendar/fullcalendar-2.6.0/lib/moment.min.js,/resource/gpcal_lex_yo_fullcalendar/fullcalendar-2.6.0/fullcalendar.js"
              
	afterScriptsLoaded="{!c.doInit}"
/>
	<aura:attribute name="recordId" type="String" access="global"/>
	<aura:attribute name="sObjectName" type="String" access="global"/>	
	<aura:attribute name="user_id" type="String" />
    
    <aura:attribute name="cal" type="Boolean" default="true" />
	<aura:attribute name="evtRec" type="List" />
    <aura:attribute name="eventId" type="String" />
    
     <aura:renderIf isTrue="{!v.cal}">
        <div id='calendar'>
        <!-- <c:EventsList evtId="{!v.eventId}" /> -->
	</div>
    </aura:renderIf>    
      
</aura:component>

CalendarViewController :

({
	doInit: function(component, event, helper){
        $('#calendar').fullCalendar({
	    	defaultView: 'month',
	    	allDaySlot: false,
	    	selectable: true,
			selectHelper: true,
			select: function(start, end) {
				
				var title = prompt("Please enter subject of event:");
				var eventData;
				if (title) {

					var action = component.get("c.createNewEvent");
					var params = { 
						start_time : start.format("YYYY-MM-DD HH:mm:ss"),
						end_time   : end.format("YYYY-MM-DD HH:mm:ss"),
						user_id    : component.get("v.user_id"),
						what_id    : component.get("v.recordId"),
						sobjectName    : component.get("v.sObjectName"),
						title      : title		
					};
					action.setParams(params);

					action.setCallback(this, function(actionResult) {				        				        
				        if( actionResult.getReturnValue() ){
				        	$('#calendar').fullCalendar( 'refetchEvents' );
				        	console.log("save successful");
				        }
				        else{

				        	alert( "Save failed for some reason." );
				        }
				    });
				    
				    $A.run(function(){
				    	$A.enqueueAction(action);						
				    });

				    

				}
				$('#calendar').fullCalendar('unselect');
			},
	    	events: function(start, end, timezone, callback) {
	    		var user_id = component.get("v.user_id");	    		
				var action = component.get("c.getEvents");
				action.setParams(
					{ 
						start_time : start,
						end_time   : end,
						user_id    : user_id		
					}
				);

				action.setCallback(this, function(actionResult) {
			        callback(JSON.parse(actionResult.getReturnValue()));
			    });
			    $A.enqueueAction(action);				
	    	},
            eventClick: function(calEvent, jsEvent, view) {
    	        console.log('gm calEvent '+calEvent);
                console.log('gm1 '+calEvent.id);
                var evtId = calEvent.id;
                component.set("v.cal",true);
                var evt = $A.get("e.c:ResultEvent");
            	console.log(evt);
                console.log(evtId);
				evt.setParams({ "pass_result": evtId });
				evt.fire();
                
		    }
	    });
	}
})


ResultEvent.evt :
<aura:event type="APPLICATION">
    <aura:attribute name="pass_result" type="String"/>
</aura:event>

app:

<aura:application extends="force:slds">
    <c:CalendarView />
    <c:EventsList />
</aura:application>


EventsList.cmp :
<aura:component controller="CalendarController" access="global">
  <aura:attribute name="eventData" type="List" access="global" />
    <aura:handler event="harshabr:ResultEvent" action="{!c.getMyEvents}" />
    
    <table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer slds-table--fixed-layout">
    <thead>
      <tr class="slds-text-heading--label">
        <th scope="col"><div class="slds-truncate" title="ID">ID</div></th>
        <th scope="col"><div class="slds-truncate" title="Subject">Subject</div></th>
        <th scope="col"><div class="slds-truncate" title="StartDateTime">StartDateTime</div></th>
      </tr>
    </thead>
    <tbody>
      <!-- Use the Apex model and controller to fetch server side data -->
      <aura:iteration items="{!v.eventData}" var="e">
        <tr>
          <th scope="row"><div class="slds-truncate" title="{!e.Id}">{!e.Id}</div></th>
          <td><div class="slds-truncate" title="{!e.Subject}">{!e.Subject}</div></td>
          <td><div class="slds-truncate" title="{!e.StartDateTime}">{!e.StartDateTime}</div></td>
          <td>
            <form class="account-form" onsubmit="{!c.deleteAccount}">
              <input type="hidden" value="{!e.Name}" class="account-name" />
             
               <!--  Use a Lightning Base Component
                To display an icon next to the label-->
             
              <lightning:button label="Delete"
                                iconName="utility:delete"
                                iconPosition="left"
                                variant="destructive"
                                />
            </form>
          </td> 
        </tr>
      </aura:iteration>
    </tbody>
  </table>
</aura:component>

 EventsListController :
({
getMyEvents: function(component, event, helper){
        var action = component.get('c.getEventss');
    	var evtIds = event.getParam("pass_result");
      	console.log('GM evtId '+evtIds);
      	action.setParams({
        	  "eventId": evtIds
      	});
    	// Set up the callback
    	var self = this;
    	action.setCallback(this, function(actionResult) {
     		component.set('v.eventData', actionResult.getReturnValue());
    	});
      	console.log("GM res "+component.get('v.eventData'));
    	$A.enqueueAction(action);
    },
  deleteAccount: function(component, event, helper) {
    // Prevent the form from getting submitted
    event.preventDefault();

    // Get the value from the field that's in the form
    var accountName = event.target.getElementsByClassName('account-name')[0].value;
    confirm('Delete the ' + accountName + ' account? (don’t worry, this won’t actually work!)');
  }
})
  • February 06, 2018
  • Like
  • 1
a.       Documents

b.      Attachments

c.       Chatter Files
  • March 07, 2014
  • Like
  • 1
I completed two trails but only show to have one. I am not sure why this isn't showing
Hi Team,

I have a requirement to import data into some particular objects from CSV which are placed at particular path at particular time.

Request you to kindly help in that.

Thanks,
  Vishnu

Hi,

I'm a beginning Force.com IDE user. Great product !

I would like to debug a web service developed by other guys, who left the company. 
This is the code for the test class:

@isTest
private class WS01_Account_GetUpdate_TEST {
    
    private static testMethod void getAccountsTest() {
        Test.startTest();
        Account acc = testUtils.createAccount('testAccount');
        insert acc;
        
        DateTime dateTimeValue = DateTime.now().addMonths(-1);
        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();
        req.requestURI = '/services/apexrest/Accounts/';
        req.httpMethod = 'GET';
        RestContext.request = req;
        RestContext.request.params.put('iRefDateTime', String.valueOf(dateTimeValue));
        RestContext.response= res;
        
        WS01_Account_GetUpdate.getAccountWithoutIdTEPORTAL();
        Test.stopTest();
    }
  }


My question is what to type in "Source to execute" in the "Execute Asynchronous" tab in Debug perspective.
I tried with:

new WS01_Account_GetUpdate_TEST().getAccountsTest();

But I'm getting :

Compile error at line 1 column 1
Type is not visible: WS01_Account_GetUpdate_TEST


Can anybody help me out here please ?

Many thanks in advance,

Patrick

User-added image

We use a property field with a standard clone button. See picture.
Now i need to create a new clone button that will copie all fields the same eccept for the status field. That should by cloning set default to "Open"
The status is a multi picklist..
Is there a way you can help me with this.
Hi All,

when I'm trying to call application event then I'm getting below error and $A.get(event) is returning undefined which is marked bold in the below code.
Error : Uncaught TypeError: Cannot read property 'setParams' of undefined
 
CalendarView.cmp  :

<aura:component controller="CalendarController" implements="force:hasRecordId,force:hasSObjectName,force:appHostable" access="global">
<aura:registerEvent name="loadMyEvent" type="harshabr:ResultEvent"/>
    
    <ltng:require styles="/resource/gpcal_lex_yo_SLDS0121/assets/styles/salesforce-lightning-design-system-ltng.css,/resource/gpcal_lex_yo_fullcalendar/fullcalendar-2.6.0/fullcalendar.css" 
	scripts="/resource/gpcal_lex_yo_jquery,/resource/gpcal_lex_yo_fullcalendar/fullcalendar-2.6.0/lib/moment.min.js,/resource/gpcal_lex_yo_fullcalendar/fullcalendar-2.6.0/fullcalendar.js"
              
	afterScriptsLoaded="{!c.doInit}"
/>
	<aura:attribute name="recordId" type="String" access="global"/>
	<aura:attribute name="sObjectName" type="String" access="global"/>	
	<aura:attribute name="user_id" type="String" />
    
    <aura:attribute name="cal" type="Boolean" default="true" />
	<aura:attribute name="evtRec" type="List" />
    <aura:attribute name="eventId" type="String" />
    
     <aura:renderIf isTrue="{!v.cal}">
        <div id='calendar'>
        <!-- <c:EventsList evtId="{!v.eventId}" /> -->
	</div>
    </aura:renderIf>    
      
</aura:component>

CalendarViewController :

({
	doInit: function(component, event, helper){
        $('#calendar').fullCalendar({
	    	defaultView: 'month',
	    	allDaySlot: false,
	    	selectable: true,
			selectHelper: true,
			select: function(start, end) {
				
				var title = prompt("Please enter subject of event:");
				var eventData;
				if (title) {

					var action = component.get("c.createNewEvent");
					var params = { 
						start_time : start.format("YYYY-MM-DD HH:mm:ss"),
						end_time   : end.format("YYYY-MM-DD HH:mm:ss"),
						user_id    : component.get("v.user_id"),
						what_id    : component.get("v.recordId"),
						sobjectName    : component.get("v.sObjectName"),
						title      : title		
					};
					action.setParams(params);

					action.setCallback(this, function(actionResult) {				        				        
				        if( actionResult.getReturnValue() ){
				        	$('#calendar').fullCalendar( 'refetchEvents' );
				        	console.log("save successful");
				        }
				        else{

				        	alert( "Save failed for some reason." );
				        }
				    });
				    
				    $A.run(function(){
				    	$A.enqueueAction(action);						
				    });

				    

				}
				$('#calendar').fullCalendar('unselect');
			},
	    	events: function(start, end, timezone, callback) {
	    		var user_id = component.get("v.user_id");	    		
				var action = component.get("c.getEvents");
				action.setParams(
					{ 
						start_time : start,
						end_time   : end,
						user_id    : user_id		
					}
				);

				action.setCallback(this, function(actionResult) {
			        callback(JSON.parse(actionResult.getReturnValue()));
			    });
			    $A.enqueueAction(action);				
	    	},
            eventClick: function(calEvent, jsEvent, view) {
    	        console.log('gm calEvent '+calEvent);
                console.log('gm1 '+calEvent.id);
                var evtId = calEvent.id;
                component.set("v.cal",true);
                var evt = $A.get("e.c:ResultEvent");
            	console.log(evt);
                console.log(evtId);
				evt.setParams({ "pass_result": evtId });
				evt.fire();
                
		    }
	    });
	}
})


ResultEvent.evt :
<aura:event type="APPLICATION">
    <aura:attribute name="pass_result" type="String"/>
</aura:event>

app:

<aura:application extends="force:slds">
    <c:CalendarView />
    <c:EventsList />
</aura:application>


EventsList.cmp :
<aura:component controller="CalendarController" access="global">
  <aura:attribute name="eventData" type="List" access="global" />
    <aura:handler event="harshabr:ResultEvent" action="{!c.getMyEvents}" />
    
    <table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer slds-table--fixed-layout">
    <thead>
      <tr class="slds-text-heading--label">
        <th scope="col"><div class="slds-truncate" title="ID">ID</div></th>
        <th scope="col"><div class="slds-truncate" title="Subject">Subject</div></th>
        <th scope="col"><div class="slds-truncate" title="StartDateTime">StartDateTime</div></th>
      </tr>
    </thead>
    <tbody>
      <!-- Use the Apex model and controller to fetch server side data -->
      <aura:iteration items="{!v.eventData}" var="e">
        <tr>
          <th scope="row"><div class="slds-truncate" title="{!e.Id}">{!e.Id}</div></th>
          <td><div class="slds-truncate" title="{!e.Subject}">{!e.Subject}</div></td>
          <td><div class="slds-truncate" title="{!e.StartDateTime}">{!e.StartDateTime}</div></td>
          <td>
            <form class="account-form" onsubmit="{!c.deleteAccount}">
              <input type="hidden" value="{!e.Name}" class="account-name" />
             
               <!--  Use a Lightning Base Component
                To display an icon next to the label-->
             
              <lightning:button label="Delete"
                                iconName="utility:delete"
                                iconPosition="left"
                                variant="destructive"
                                />
            </form>
          </td> 
        </tr>
      </aura:iteration>
    </tbody>
  </table>
</aura:component>

 EventsListController :
({
getMyEvents: function(component, event, helper){
        var action = component.get('c.getEventss');
    	var evtIds = event.getParam("pass_result");
      	console.log('GM evtId '+evtIds);
      	action.setParams({
        	  "eventId": evtIds
      	});
    	// Set up the callback
    	var self = this;
    	action.setCallback(this, function(actionResult) {
     		component.set('v.eventData', actionResult.getReturnValue());
    	});
      	console.log("GM res "+component.get('v.eventData'));
    	$A.enqueueAction(action);
    },
  deleteAccount: function(component, event, helper) {
    // Prevent the form from getting submitted
    event.preventDefault();

    // Get the value from the field that's in the form
    var accountName = event.target.getElementsByClassName('account-name')[0].value;
    confirm('Delete the ' + accountName + ' account? (don’t worry, this won’t actually work!)');
  }
})
  • February 06, 2018
  • Like
  • 1
I wanted to create a button in the leads search view, what I found was a way to create a custom text field with formula HYPERLINK to open a visualforce page and then IMAGE function inside to show the image as button.

The problem I have is HYPERLINK or other functions will open into another page or will atleast reload the current page.

Requirements that I had to consider :
1. create a button for each row of leads in custom view or any view that on click calls our external api to do some task.

2. The page should not reload or redirect to some other page

3. It should be like point and click and done.

Since the above solution cannot work(I think), now I am thinking of creating a drop down field with a trigger to call api on field update.

If you can guide me how can I solve these requirements it will be of great help.If my first solution is not possible, please do provide alternatives that can be used in this case.

My biggest problem is I have never seen an salesforce app in production or used salesforce for a company or have any idea how pros do it. I wish there was some standards like I know I am creating hacks and tricks but is there a right way(developer standard) to do this.
Hi,
 How to send any file or document  attachment  through the web to Salesforce lead.


thanks
Hi,

We have a external id custom field which is unique and case sensitive. After entering a duplicate value it throwns an error. 'Error: Duplicate value on record: 000023333'. We need to translate this error message text in Japnese. Please help.
Hi,
Please let me know how i can login Salesforce using userInfo.getSessionId.

Thanks in advance
I'm writing an apex batch class to migrate data from one object to another. How to delete only the records of old object which are successfully inserted into the new object?
Hi,

I am trying to create a time dependent workflow action to send an email to the creator after one hour if the status remains "In progress"
I see the entry in the monitoring queue but nothing is happening after the "Scheduled Date"

WF evaluation criteria is "Created"

Thanks,
Krishna.
I want to ask if there is a method in Salesforce for checking if a given string is a DateTime format string?
There is custom button created (it redirects to VF on click of it) & placed on standard opportunity page layout.
 There is inline VF page present on same standard opportunity page layout.
 
Is it possible to control the appearance of this custom button (Show/Hide) based on the some fields value of opportunity records via JS or any approach without creating multiple page layouts or overriding std opportunity page layout with Vf page?
 
I looked into some of blogs but those solution will work only for the buttons present inside inline VF page or on overriding std page layouts
Ex : http://blogatsalesforce.blogspot.in/2015/04/enable-disable-buttons-on-standard.html
 
 
  • April 29, 2017
  • Like
  • 0