Skip to main content

Posts

Showing posts from 2016

ISV App Strategy

App Type ISVforce App app that extend Sales or Service Cloud can be sell only to existing Salesforce customer. if we use some Salesforce licence dependencies feature, need to make sure the user also have licence from Salesforce. our customer have to purchase the license from Salesforce Licence type mostly Sales and Service cloud Force.com Embedded app (OEM Embedded app) app that does not rely on Sales cloud or Service cloud functionality. can be sell to existing customer or customer who does not use Salesforce at all. have access to App Cloud platform.Although they have access to certain Sales and Service cloud object such Leads,Opportunities they can't surface those to customer. by contract,Salesforce does not give permission to rebuild Sales or Service Cloud functionality within OEM Embedded app. the licence is embedded in application for new customer and existing customer but existing customer can choose to assign their ISV app licence rather than using embedded

Salesforce1 Mobile Basic : Creating Object-Specific Quick Actions

Five types of object-specific action: Object-specific CREATE ACTION create records that are automatically associated with related records. Object-specific UPDATE ACTION make it easy for users to edit records. You can define the fields that are available for update. Object-specific LOG A CALL actions let users enter notes about calls, meetings, or other interactions that are related to a specific record. Object-specific CUSTOM ACTIONS invoke Lightning components, Visualforce pages, or canvas apps that let users interact with or create records that have a relationship to an object record.The Visualforce page for an object-specific custom action must include the standard controller for the relevant object. SEND EMAIL ACTION , available only on CASES , give users access to a simplified version of the Case Feed Email action on Salesforce1. Refer to trailhead : Creating Object-Specific Quick Actions

Entity is not api accessible when saving Apex class

Entity is not api accessible  The error can be due to : The object name is not stated correctly ,it happens when we use custom object we forgot to include __c : Example : Use incorrectly MyObject instead of MyObject__c Or some typo,I am not sure why it didnot give proper error but some of the typo below my cause some issue .Note service  is not declared in the code below. Opportunity_Service service1 = new Opportunity_Service (); List < Opportunity_Service . Result > results = service . run ( opportunities );

System.UnsupportedOperationException: ConnectApi methods are not supported...

I am using ConnectorAPIHelper to post Chatter notification from apex code.When I run my apex test class it giving this exception : System.UnsupportedOperationException: ConnectApi methods are not supported in data siloed tests. Please use @IsTest(SeeAllData=true). It seems in order to cover the class that use ChatterApi, the test class need to be SeeAllData=true . In my case, because I only have one line method that call ChatterApi , I think it's better use Test.isRunningTest instead of SeeAllData=true. public static void postChatter (){ //exclude this from testing because in order to test ChatterApi ,we must set SeeAllData=true. //This class is test separately so it can be ignore for this testing. if (! Test . isRunningTest ()){ //send chatter notification ConnectApi . FeedItem fi = ( ConnectApi . FeedItem ) ConnectApiHelper . postFeedItemWithMentions ( Network . getNetworkId (), ' me ' , ' Hi , ' + recipie

System.AsyncException: trigger must be associated with a job detail

System.AsyncException: trigger must be associated with a job detail I am writing test class for schedule and bump into this exception.The reason is , make sure no space at jobName. The class can be call by : System.schedule(jobName, cronExpression, schedulableClass) ; Notice this will throw the exception . 'Opp_Update_Schedule 5.00 ' // Schedule the test job String jobId = System . schedule ( ' Opp_Update_Schedule 5.00 ' , CRON_EXP_DAY , new Opportunity_Update_Schedule ( 100 )); This will not throw exception :'Opp_Update_Schedule'. Remove space, I haven't test with special character (you might want to test) but I remove it anyway and it run. // Schedule the test job String jobId = System . schedule ( ' Opp_Update_Schedule ' , CRON_EXP_DAY , new Opportunity_Update_Schedule ( 100 )); Have a nice day.

User is already a Member of this group.

When we deactivate the user who is member of Chatter group, the user will be invisible from the Chatter Group.We not able to find the user using this query : SELECT Id, CollaborationGroupId, MemberId FROM CollaborationGroupMember WHERE CollaborationGroupId = : groupId Also the user is not inside Chatter Group --Members . But when we activate the user, automatically it will be appear in Chatter Group. All of this is handled by Salesforce. Please note this when we plan to add user into the Group automatically because we may bump into exception below :  User is already a Member of this group.  So we need to verify if the user is a member of the group before adding it.

Finding Distinct in Report using Formula

I never thought this can be done using formula, but yes.Please refer to here . Scenario : We want to see total how many Account that has Opportunities. Create one formula field in Account object with return type Number and 0 Decimal place.Place 1 at Formula field. Example of the report below, we want to know how many Account that has Opportunity. So we click Customize Report, Click on Unique Account -> Choose Summarize this Report ,select Sum and Apply. Total of Account is 8.

Processes Can Execute Actions on More Than One Criteria but...

Previously before Summer '16 we are not able to evaluate the next criteria if first criteria is correct.So once the process fall into true condition , implement the action and that's it.It will stop. In Summer'16 : Processes Can Execute Actions on More Than One Criteria  , we able to evaluate next criteria once the process builder process the conditon for current criteria.(ugh ...not sure I am explaining well). It is something like this : Previously it works something like this.Notice that if condition1 is fulfilled , it will never go to else condition. if ( condition1 = t = rue ){ //logic } else if ( condition2 == true ){ //logic } Now , we can proceed with next criteria ...it can be like this : if ( condition1 == true ){ //logic } if ( condition2 == true ){ //logic } In order for it to evaluate the next criteria, just click on the STOP and it will give the screen shot like below. REMEMBER ,THIS FEATURE DOES NOT W

Process Builder not working during record insertion and fail to launch Flow

I created Process Builder to automatically add user into Chatter group , refer to here .It works fine when I update the user but it fail when I create new user. An error occurred at element Add_User_to_All_Chatter_Group (FlowRecordCreate). INSERT --- INSERT FAILED --- ERRORS : (MIXED_DML_OPERATION) DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): CollaborationGroupMember, original object: User I am assuming during creation, the user id is not yet committed, so it not able to set variable in Flow.After do some googling , I found some solution that can be applied on my case. I also add new Record Lookup in my Flow, to check if the user already exist in Chatter group and Decision when the Lookup Result is not found. Good thing, due to this I can remove custom field that I used to indicate if the User already added into the group. In Process Builder , I use Scheduled Actions so I have to use  'Formula evaluates

Automatically adding user into Chatter group using Process Builder

I am looking for solution to automatically add user to Chatter group and found this interesting solution using Flow Trigger and Workflow rule.However I am not able to implement it because Flow Trigger is pilot feature not GA feature.If I really want it, I can just call Salesforce Support to enable it but I m kinda of lazy. But I just tweak this solution by using Process Builder.I think the solution is available out there but let me just update mine. Please vote for this idea : Automatically add individuals to Chatter Group upon provisioning new user If you are enabling namespace you might face this issue :  Workflow Action Failed to Trigger Flow when triggering Flow created after enabling a namespace  , and this solution might not work for you. Step 1 : Create a Chatter Group Step 2: Create custom field datatype checkbox in User object. This is depending on how you want to implement logic to add user.In my case, if this               checkbox is false it will add user to th

Visualforce error : Maximum view state size limit (135KB) exceeded. Actual view state size for this page was 136.031KB

I created a visualforce page to display report that join between Attachment and Content version based on Attachment Parent Type.I bumped into view state exception when retrieving attachment on Opportunity that contains more than 1000 row. Note that listAttachment and listMigrationObject is the biggest contributor on this exception. Below I share snippet on how I retrieve listAttachment that causing exceed ViewState. listAttachment = [ Select Name , Id , ParentId , Parent . Type , Owner . Name , Owner . Id , Owner . IsActive , ContentType , isPrivate from Attachment where Parent . Type =: selectedParent ]; Map < Id , Attachment > mapAttachment = new Map < Id , Attachment >(); for ( Attachment att : listAttachment ){ mapAttachment . put ( att . Id , att ); } I change the code to below : for ( Attachment att : [ Select Name , Id , ParentId , Parent . Type , Owner . Name , Owner . Id , Owner . IsActive , ContentType , isPrivate from

Style like Homepage in Salesforce

The requirement is to create visualforce and make it as one of Homepage component.The style should be same as Homepage style. It works until a user comes to me and said; "I notice the blue section in the component is different from Homepage component." Krik... Krikk.. I didn't notice that until I have to print screen and put it side to side.Oh,actually it is different, I thought it just screen reflection.So how can I get the Homepage style color. This is my page definition,note I use tabStyle = Account .So it gives me the blue color same like Account tab. <apex:page controller= "MyController" readOnly= "true" showHeader= "false" standardStylesheets= "true" sidebar= "false" applyHtmlTag= "false" applyBodyTag= "false" docType= "html-5.0" > <apex:pageBlock title= "My Account" tabstyle= "Account" > By default if we are not defining

Data Management : Importing and Exporting Data

Note: All credit goes to Salesforce, I am just a developer who enjoy playing trailhead and try to make note to myself. Importing Data Two methods of importing data :  When to use Data Import wizard : Need to load less than 50000 records The objects that need to be imported is supported by wizard No need automation process When to use Data Loader : Need to load 50000 to 5 Million records. The object is not supported by Data Import Wizard Want to schedule regular data loads Data Import Useful tips for cleaning data using Excel Salesforce Trailhead link :  Importing Data Exporting Data Two methods of exporting data Data export wizard - accessible through the Setup menu. It allows you to export data manually once every six days (for weekly export) or 28 days (for monthly export). You can also export data automatically, at weekly or monthly intervals. Data Loader -this is a client application that you must install separately. It can be operated either

Data Modelling :Creating object relationship

Note: All credit goes to Salesforce, I am just a developer who enjoy playing trailhead and try to make note to myself. Types of Object Relationship Lookup relationship that links one object to another object. can be used to create 1:1 or 1:M relationship Master Detail parent:child relationship. master record controls certain behavior of the details or subdetail record. ownership and sharing is determined by master record. when master record is deleted,the detail also will be deleted along with it. master detail relationship always required on detail record. use for tight binding between two objects master object can also contain rollup summary field. Differences between Lookup and Master detail relationships Master detail relationship cannot create detail without master detail is also deleted when master is deleted the sharing rules is inherited from the master record number of master detail relationships are limited based on platform edition and licence

Apex Basics & Database : Writing SOSL Queries

Note: All credit goes to Salesforce, I am just a developer who enjoy playing trailhead and try to make note to myself. What is SOSL? Salesforce Object Search Language (SOSL) is a Salesforce search language that is used to perform text searches in records . Use SOSL to search fields across multiple standard and custom object records in Salesforce. SOSL is similar to Apache Lucene . Differences and Similarities Between SOQL and SOSL Like SOQL, SOSL allows you to search your organization’s records for specific information. Unlike SOQL, which can only query one standard or custom object at a time, a single SOSL query can search all objects. They are same in :  allows you to search your organization’s records for specific information They are not same: SOQL can only query one standard or custom object at a time, a single SOSL query can search all objects. SOSL matches fields based on a word match while SOQL performs an exact match by default (when not using wildcards).

Process Builder Exception : The record couldn’t be saved because it failed to trigger a flow

The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 3xxxxxxxxxxxxxx.  Contact your administrator for help. The process builder is to update Country Contact with Account Country if the Contact Country is blank based on condition below : When user uploads the Contact data without Account data it will throw an exception and I receive an email contains information below which is not so helpful. An error occurred at element myDecision (FlowDecision). The flow failed to access the value for myVariable_current.Account.Country__c because it hasn't been set or assigned. Logically it should not run the process builder at the first place because the conditions are not fulfilled.I plan to raise ticket to Salesforce until I accidentally change the sequence of the conditions to : Note I put AccountId condition before checking the Account Country__c.I run another test and wallahhh...the exception is gone.Con

Apex Basics & Database Writing SOQL Queries

Note: All credit goes to Salesforce, I am just a developer who enjoy playing trailhead and try to make note to myself. Querying Related Records Get child records related to parent record Account [] acctsWithContacts = [ SELECT Name , ( SELECT FirstName , LastName FROM Contacts ) FROM Account WHERE Name = ' SFDC Computing ' ]; // Get child records Contact [] cts = acctsWithContacts [ 0 ]. Contacts ; System . debug ( ' Name of first associated contact: ' + cts [ 0 ]. FirstName + ' , ' + cts [ 0 ]. LastName ); Querying Record in Batches By Using SOQL For Loops With a SOQL for loop, you can include a SOQL query within a for loop. The results of a SOQL query can be iterated over within the loop. SOQL for loops use a different method for retrieving records—records are retrieved using efficient chunking with calls to the query and queryMore methods of the SOAP A

Apex Basics & Database : Manipulating Records with DML

Note: All credit goes to Salesforce, I am just a developer who enjoy playing trailhead and try to make note to myself. Manipulating Records with DML DML statements that are available: insert update upsert-creates new records and updates sObject records within a single statement, using a specified field to determine the presence of existing objects, or the ID field if no field is specified. delete undelete merge-merges up to three records of the same sObject type into one of the records, deleting the others, and re-parenting any related records. Each DML statement accepts either a single sObject or a list (or array) of sObjects. Operating on a list of sObjects is a more efficient way for processing records . Database Methods Apex contains the built-in Database class, which provides methods that perform DML operations and mirror the DML statement counterparts. These Database methods are static and are called on the class name. Database.insert() Database.update()

Apex Basic and Database :Using SObject

Note: All credit goes to Salesforce, I am just a developer who enjoy playing trailhead and try to make note to myself. Relationship between Sobjects and Salesforce record Every record in Salesforce is natively represented as an sObject in Apex . For example, the Acme account record corresponds to an Account sObject in Apex. The fields of the Acme record that we can view and modify in the user interface can be read and modified directly on the sObject as well. Each Salesforce record is represented as an sObject before it is inserted into Salesforce . Likewise, when persisted records are retrieved from Salesforce, they’re stored in an sObject variable. Some rules used for API names for custom objects and custom fields. For custom objects and custom fields, the API name always ends with the __c suffix. For custom relationship fields, the API name ends with the __r suffix. For example: A custom object with a label of Merchandise has an API name of Merchandise__c. A custom fie

Apex Basic and Database : What is Apex ?

Note: All credit goes to Salesforce, I am just a developer who enjoy playing trailhead and try to make note to myself. What is Apex? programming language that uses Java-like syntax and acts like database stored procedures. Apex enables developers to add business logic to system events, such as button clicks, updates of related records, and Visualforce pages. source  Apex is: Hosted —Apex is saved, compiled, and executed on the server—the Force.com platform. Automatically upgradeable —Because compiled code is stored as metadata in the platform, Apex is automatically upgraded as part of Salesforce releases. Object oriented —Apex supports classes, interfaces, and inheritance. Strongly typed —Apex validates references to objects at compile time. Multitenant aware —Governer limit.Because Apex runs in a multitenant platform, it guards closely against runaway code by enforcing limits, which prevent code from monopolizing shared resources. Integrated with the

Lightning Experience Development : User Interface Development Consideration

Note: All credit goes to Salesforce, I am just a developer who enjoy playing trailhead and try to make note to myself. Two models of developing web app Page Centric web application model great to serve basic functionality. not offer great user interactive experience server side generate user interaction App Centric mode great user experience client side Three options that offered by Salesforce Classic Visualforce UI Generation -  Server-side Data and Business Logic- Apex standard or custom controller Workflow User requests a page The server executes the page’s underlying code and sends the resulting HTML to the browser The browser displays the HTML When the user interacts with the page, return to step one. Pros Tried and true model Easy to implement for greater productivity Naturally splits large applications into small, manageable page Has built-in metadata integration Caveats Limited interactivity (aside from added JavaScript functionality

Lightning Experience

Note: All credit goes to Salesforce, I am just a developer who enjoy playing trailhead and try to make note to myself. Which one I should use?Lightning Experience or Salesforce Classic? Lightning Experience might be right for some or all of your org if: Your sales team does business-to-business sales using accounts, contacts, leads, opportunities, custom objects, and the other sales features supported in the new user interface. You want to pilot the new user interface with a group of sales reps. You’re looking to reboot your Salesforce implementation. This is a great opportunity to introduce new features because you’re doing change management anyway. Salesforce Classic might be right for you if: Your sales team makes regular use of features that aren’t yet available in Lightning Experience, such as quotes, forecasting, or territory management. You primarily use customer service tools or other non-sales features. You want a single experience for your sales and service teams.

Data Modelling :Creating custom object and fields

Note: All credit goes to Salesforce, I am just a developer who enjoy playing trailhead and try to make note to myself. Best Practices for Custom Objects and Fields Unique naming: Make object and field names and labels concise, specific, and descriptive. And very importantly, unique. For example, if your recruiting app’s Position object has a field named Skill Set, use something like Candidate Skill Set on the Candidate object to describe applicants’ skills. Thoughtful architecture : When adding fields to an object, what’s the cleanest and most efficient way to capture data? For example, instead of a long list of checkboxes to track the regions that currently have a particular position open, use a picklist. Default field values : Don’t assign default values to fields that are both required and unique, as this can cause uniqueness errors. Careful renaming : If you’ve renamed objects or fields, check that these items reflect the new names: List view names Standard report names

Data Modelling :Understanding Standard and Custom Object

Note: All credit goes to Salesforce, I am just a developer who enjoy playing trailhead and try to make note to myself. In relational database such Oracle,MySql we use table to store data but in Salesforce we use object.Here the summary of term that use in relational database and the term that we use in Salesforce. Relational Database Salesforce Table Object Column Field Row Record Standard Object - objects included by Salesforce by default such as Account,Opportunity,Leads. Custom Object -object that created by user/developer to support the need of organization. Fields and Relationships Identitiy - ID automatically assigned by Force.com.Usually 15 case sensitive characters.It is unique. System Fields Default read only field created by Force.com upon object created such as CreatedDate,CreatedBy,LastModifiedDate etc. Name field required but not unique, depend on how we want to identify the record. Custom