• jvolkov
  • NEWBIE
  • 25 Points
  • Member since 2008

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 28
    Questions
  • 45
    Replies

Is it best practice to use names when referencing fields such as user roles, profiles, or record types?  I've been told that it is and although I can see the value in this for something such as a username that will not change, I'm wondering why it is known as as best practice for something that can change such as user roles.

 

It seems that using the user role id with a note of the present name would be more beneficial since the ID will not change.  For example, if SOQL is writen with a WHERE statement that filters on the UserRole.Name called "Salesperson", and down the road that role name is changed to "Account Executive", won't that cause the SOQL query to return a null value?  Where is if the WHERE statement instead filters on UserRoleId even though the role name has been changed the ID remains the same value thus the SOQL query will still return the expected values.

 

Is this just a preference?  What is the main reason to use names instead of IDs?

 

Thanks

This field reference is not working, not sure why.  Basically it seems that it is assuming the reference field is blank even though it is populated.

 

 

for (Opportunity opp: trigger.new) {
	
	if(opp.CustomUserField__r.UserRoleId=='00E60000000oDgG') {
		//do this
	}
}

 

 

 

Thanks

 

When are lead assignment rules triggered?

 

 

  • When the lead is created and meets the criteria?

OR

  • When the lead is created or edited and meets the criteria?

 

 

What is the order of execution with lead assignment rules and workflow rules?  Which is updated first?

 

Is there official documentation for any of this?

Has anyone had any luck using the Primary_Contact__r field values in formula fields?  They appear to all return null values even though the opportunity has a primary contact.

 

Example:  An opportunity has a primary contact selected but Primary_Contact__r.Id = null.  Would expect Primary_Contact__r.Id to equal the primary contact's Id.

Hello,

 

First off, do not have an enterprise edition so using person accounts is off the table, unfortunately.  Without using person accounts, what are the best practices to building a custom object(s) that will store the consumer data while having a one-to-many relationship with both accounts and opportunities?  As far as I can tell, custom objects can only be the child in a master-detail relationship with a standard object which would mean there would be one account to many consumers when in fact we need that to be the other way around, one consumer to many businesses.  It seems then the only way to do that would be to not use the standard objects account and opportunity, and instead build three custom objects with the consumer object being the parent in each of the master-detail relationships.

 

Anybody built something similiar in Group or Professional edition?  What were some of the biggest challenges and disadvantages?

 

Thanks

Is it possible to query Multi-Select Picklists to lookup against a Set?  

 

For example:


Instead of this 

SELECT Id, MultiPicklist__c from CustObj__c WHERE MultiPicklist__c includes ('AAA;BBB','CCC')

Can you do something like this?

I get an error when attempting to save this so I'm wondering what the correct syntax, if possible, for something like this would be.

Set<String> singlePicklistSet = new Set<String>();  /*the set of values from a single picklist*/
SELECT Id, MultiPicklist__c from CustObj__c WHERE MultiPicklist__c includes :singlePicklistSet  /*is at least one of the values from MultiPicklist__c in the set of values from the single picklist?*/

Is there a report type that returns usage of standard email templates?  I know about the HTML Email Status Report but that is returning no results even after turning all filters off.

 

-Thanks

From what I've read in the documentation Apex is not available for Group Edition.  I want to create a VisualForce page for a client with Group Edition that uses an Apex extension controller.  Is this at all possible?  Maybe the logic I was going to write in Apex can be placed directly within Visualforce?

 

I'm trying to render a single VF page table that basically looks like an activity report.  It requires getting data from the lead, account, and task objects.

 

Thanks

This is a very slight modification to the chatterMiniFeed class from the Chatter MiniFeed app, part of the Chatter Combo app.  I'm not sure if this was the most efficient method to add the body but it works.

 

 

// Jonathan Hersh - jhersh@salesforce.com - 2/26/2010
public class chatterMiniFeed {
    public notification[] notes { get; set; }
    public Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
    public Map<string,string> prefixes       = getSObjectPrefixes();
    
    public chatterMiniFeed() {
        doRefresh();
    }
    
    public pageReference doRefresh() {
        string uID = UserInfo.getUserId();
        string ptype;
        
        notes = new notification[] {};
        
        NewsFeed[] nfs = [select id, createdbyid, createddate, createdby.name, type, feedpost.type,
            parentid, parent.name, FeedPost.Body,  /*added FeedPost.Body on 10/11/2010 by JV*/
                (select createddate, createdbyid, parentid, createdby.name, feeditemid
                    from FeedComments 
                    where createdbyid <> :uID
                    order by createddate desc limit 30),
                (select FieldName from FeedTrackedChanges ORDER BY Id DESC)
            from NewsFeed
            where not FeedPost.Body like '%Google Alert%'  /*added FeedPost.Body on 10/11/2010 by JV*/
            order by createddate desc limit 200];
        
        for( NewsFeed nf : nfs ) {
            if( nf.type == 'LinkPost' )
                ptype = 'link';
            else if( nf.type == 'TextPost' )
                ptype = 'note';
            else if( nf.type == 'ContentPost' )
                ptype = 'file';
            else if( nf.type == 'UserStatus' )
                ptype = 'status update';
                
            if( nf.type == 'TrackedChange' && nf.feedtrackedchanges.isEmpty() )
                continue;
                
            string obtype = getPrefix( nf.parentid, 0 );
            string postURL;
            
            if( obtype == 'User' )
              postURL = '/_ui/core/userprofile/UserProfilePage?u='+ nf.parentid + '&';
            else if( obtype == 'CollaborationGroup' )
              postURL = '/_ui/core/chatter/groups/GroupProfilePage?g='+ nf.parentid + '&';
            else
              postURL = '/' + nf.parentid + '?';
              
            postURL += 'ChatterFeedItemId=' + nf.id;
            
            // Tracked change from someone else on a record that we follow
            if( nf.type == 'TrackedChange' && nf.createdbyid != uId ) {
              if( nf.FeedTrackedChanges[0].fieldname == 'created' )
                  notes.add( new notification( (''+nf.createdbyid), nf.createdby.name, ' created a new <b>'+
                  getPrefix( nf.parentid, 1 ) +'</b>: <a href="' + postURL +'" target="_top">'+ nf.parent.name +'</a>.', nf.FeedPost.Body, nf.createddate ) );
                else
                  notes.add( new notification( (''+nf.createdbyid), nf.createdby.name, ' updated <b>'+ nf.feedtrackedchanges[0].fieldname +'</b> on'+
                  ' <a href="' + postURL +'" target="_top">'+ nf.parent.name +'</a>.', nf.FeedPost.Body, nf.createddate ) );
            // Post from someone else on another object that we follow
            } else if( nf.parentid != uId && nf.CreatedById != uID )
                notes.add( new notification( (''+nf.createdbyid), nf.createdby.name, ' posted a '+ 
                  ( ptype != 'status update' ? ptype + ' on <a href="' + postURL +'" target="_top">'+ nf.parent.name +'</a>.' : 
                  '<a href="'+ postURL +'" target="_top">' + ptype + '</a>.' ), nf.FeedPost.Body, nf.createddate ) );
            // We don't show our own wall posts...
            else if( nf.createdbyid != uId && nf.parentid == uId )
                notes.add( new notification( (''+nf.createdbyid), nf.createdby.name, ' posted a '+ ptype +' on <a href="' + postURL +'" target="_top">your profile</a>.', nf.FeedPost.Body, nf.createddate ) );
            
            // ...but we do show comments from other people about them
            for( FeedComment fc : nf.feedcomments )
                if( fc.createdbyid != uID )
                    notes.add( new notification( (''+fc.createdbyid), fc.createdby.name, ' commented on '+
                        ( nf.createdbyid == uID ? 'your' : 'a' ) + ' post on '+
                        ( nf.parentid == uID ? '<a href="'+ postURL +'" target="_top">your profile</a>.' : 
                            '<a href="' + postURL +'" target="_top">'+ nf.parent.name +'</a>.' ),
                        nf.FeedPost.Body, fc.createddate ) );
        }
            
        // This will error if you haven't deployed the chatter messages objects, so we'll try to detect
        // ahead of time if it's been deployed
        // All messages and replies sent to us      
        /*if( Schema.SObjectType.Chatter_Message_Recipient__c.fields.chatter_message__c.isAccessible() ) {
            Chatter_Message_Recipient__c[] recips = [select chatter_message__c, chatter_message__r.ownerid, chatter_message__r.owner.name,
                chatter_message__r.parent__c, chatter_message__r.parent__r.ownerid, createddate, chatter_message__r.subject__c
                from Chatter_Message_Recipient__c
                where recipient__c = :UserInfo.getUserId()
                and chatter_message__r.ownerid <> :UserInfo.getUserId()
                order by createddate desc limit 200];
                
            for( Chatter_Message_Recipient__c cmr : recips ) {           
                if( cmr.chatter_message__r.parent__c != null && cmr.chatter_message__r.parent__r.ownerid == UserInfo.getUserId() )
                    notes.add( new notification( ''+ cmr.chatter_message__r.ownerid, cmr.chatter_message__r.owner.name,
                        ' replied to your ',
                        cmr.createddate, cmr.chatter_message__c, 'message', cmr.chatter_message__r.subject__c, '/apex/chatterMessages' ) );
                else if( cmr.chatter_message__r.parent__c != null )
                    notes.add( new notification( ''+ cmr.chatter_message__r.ownerid, cmr.chatter_message__r.owner.name,
                        ' replied to a ',
                        cmr.createddate, cmr.chatter_message__c, 'message', cmr.chatter_message__r.subject__c, '/apex/chatterMessages' ) );
                else
                    notes.add( new notification( ''+ cmr.chatter_message__r.ownerid, cmr.chatter_message__r.owner.name,
                        ' sent you a ',
                        cmr.createddate, cmr.chatter_message__c, 'message', cmr.chatter_message__r.subject__c, '/apex/chatterMessages' ) );
                
            }
        }*/
    
        // Sort in descending chronological order
        sortNotes( notes );
        
        return null;
    }
    
    public class notification {
        public string uid       { get; set; }
        public string uname     { get; set; }
        public string msg       { get; set; }
        public string body      { get; set; }  /*added FeedPost.Body on 10/11/2010 by JV*/
        public string timestr   { get; set; }
        
        public long timestamp   { get; set; }
        
        public notification( string uid2, string uname2, string msg2, string body2, Datetime dt ) {
            uid = uid2;
            uname = uname2;
            msg = msg2;
            body = body2;  /*added FeedPost.Body on 10/11/2010 by JV*/
            timestr = relativeTime( dt );
            timestamp = dt.getTime() / 1000;
        }
        
        public string relativeTime( Datetime dt ) {
            long diff =  ( Datetime.now().getTime() - dt.getTime() ) / 1000;
            string unit;
            
            if( diff < 60 )
                unit = 'second';
            else if( diff < 60 * 60 ) {
                diff /= 60;
                unit = 'minute';
            } else if( diff < 60 * 60 * 24 ) {
                diff = diff / 60 / 60;
                unit = 'hour';
            } else {
                diff = diff / 60 / 60 / 24;
                unit = 'day';
            }
            
            if( diff > 1 )
                unit += 's';
                
            return diff + ' ' + unit + ' ago';
        }
    }
    
    public static void sortNotes(List<notification> items){
        List<notification> resultList = new List<notification>();
            
        //Create a map that can be used for sorting 
        Map<long, List<notification>> noteMap = new Map<long, List<notification>>();
            
            for(notification ob : items){
                    if(noteMap.get(ob.timestamp) == null)
                        noteMap.put(ob.timestamp, new List<notification>()); 

                    noteMap.get(ob.timestamp).add(ob);
            }
        
            //Sort the keys
        
            List<long> keys = new List<long>(noteMap.keySet());
            keys.sort();       
            
            for(long key : keys)
                resultList.addAll(noteMap.get(key));      
        
        //Apply the sorted values to the source list. descending order
        items.clear();
        
        for(integer i = resultList.size()-1; i >= 0; i--)
            items.add(resultList[i]);   
    }
    
    public string getPrefix( ID obID, integer t ) {
      string pref = (''+obID).substring(0,3);
      
      if( !prefixes.containsKey( pref ) )
        return '';
        
      return prefixes.get( pref ).split(':').get( t == 0 ? 0 : 1 );
    }
    
    // Calculate 3-letter prefixes for objects in this org
    // so we can decode IDs that are passed to us
    public Map<string,string> getsObjectPrefixes() {
      Map<string,string> ret = new Map<string,string> ();
      
      for( string s : gd.keySet() ) {
          Schema.Sobjecttype ob = gd.get( s );
          Schema.Describesobjectresult sob = ob.getDescribe();
          
          if( sob.getKeyPrefix() == null )
              continue;
              
          if( !sob.isFeedEnabled() )
              continue;
          
          ret.put( sob.getKeyPrefix(), sob.getName() + ':' + sob.getLabel() );
      }
  
      return ret;
    }
    
    public static testmethod void runTest() {
      Profile p = [select id from Profile where usertype='Standard' limit 1];
      User u = new User(alias = 'standt', email='standarduser@kwutang.demo', 
                        emailencodingkey='UTF-8', lastname='Testing1', firstname='Testing', languagelocalekey='en_US', 
                        localesidkey='en_US', profileid = p.Id, 
                        timezonesidkey='America/Los_Angeles', username='standarduser@kwutang.demo');        
        
        try {
          insert u;
          insert new EntitySubscription( subscriberid = userinfo.getuserid(), parentid = u.id );
        } catch( Exception e ) {}
        
        system.assertNotEquals( null, u.id );
        
        system.runAs( u ) {
        FeedPost fp = new FeedPost();
        fp.body = 'Testing search';
        fp.linkurl = 'http://google.com';
        fp.title = 'google';
        fp.ParentId = userinfo.getuserid();
        insert fp;
        
        UserFeed uf = [select id from UserFeed
          where parentid = :userinfo.getuserid()
          and feedpost.body = 'Testing search'];
        
        FeedComment fc = new FeedComment();
        fc.feeditemid = uf.id;
        fc.commentbody = 'new search comment!';
        
        insert fc;
        }
      
        chatterMiniFeed cmf = new chatterMiniFeed();
    }
}

 

 

I see a potential problem with users using Chatter instead inserting notes or activities.  The great thing about notes is a future record owner can look back at notes for an indefinite period of time.  With activities sales managers can report and track what their sales teams have been doing.  Do we lose these things if users are chatting about notes, calls, and meetings instead of "recording" them.

 

How do you plan on dealing with this situation in your org?

 

What reporting capabilities will Chatter have?

 

Can a trigger be created to automatically create a completed activity or a new note based off a post with certain phrases or keywords like "left a voicemail" or "sent an email"?

What are some methods to roll up child account data to the parent account level?

 

A parent account has three child accounts, want the maximum value of a field of all four accounts.

 

For example:

 

ChildRecord1.Field1 = 5

ChildRecord2.Field1 = 2

ChildRecord3.Field1 = 9

ParentRecord.Field1 = 7

 

ParentRecord.Field1Max = 9

 

Out of the four accounts themaximum field value is 9.  How can this be returned to the parent level?

-Thanks

Installed a Twitter Search Widget app that does a search on twitter then displays the results directly inside the Salesforce.com page.  For IE 7.0 users, this is triggering the "Do You Want To Display the Nonsecure Items?" popup.

 

We do not want to disable the popup as it has its uses for other websites but do not want it to be triggered by this Twitter Search Widget?   Is there code we can add to the visualforce page or component that can prevent this?

 

-Thanks

  • September 24, 2009
  • Like
  • 0

How can a scrollbar be entered into this code?

 

 

<apex:page standardController="account"> <c:TwitterSearchWidget search="{!account.Name}" title="Twitter Search Widget results for..." caption="{!account.Name}" loop="true" width="1100" height="500" shellbackground="#8a9ebe" shelltext="#ffffff" tweetbackground="#f3f3ec" tweettext="#000000" links="#8a9ebe" /> </apex:page>

 

 

 

  • September 21, 2009
  • Like
  • 0

Need to print out entire chain of a record's activity history.  This is possible to view under "Activity History" by choosing "View All", but how does one print this information?  Would also like to email this information to an outside organization.

 

-Thanks

When I attempt to import or refresh a report in Excel 2007 using the Excel Connector I am getting an error that ends with "Cannot locate the Internet server or proxy server".

 

Has this happened to anybody else?  What was the resolution?

How could a custom formula be written to return true if a text field contains an apostrophe?

 

The formula CONTAINS(Title, """) returns this error, Error: Syntax error. Missing ".

 

Any way around this?

 

-Thanks

Hello,

 

Is it possible to write an APEX trigger or S-Control that would merge duplicate records based on certain duplicate rule.

 

For example, is it possible to automatically merge records upon insert or update if a lead's full name and website match that of a contact's full name and contact's account website?

 

-Thanks

Is there a way to show in the Contact object that a contact is the primary contact listed in an attached opportunity?

 

-Thanks

I just updated to the latest version of Eclipse and the when I right click > go to Force.com, the link to deploy is no longer there.  Where did it go?

Need to return in a view or a  report alll leads or accounts that do not have an open activit. 

 

Want to create a field that returns how many open activities a record has.  Is there a way to this using custom formula field or reports?

 

-Thanks

Is it best practice to use names when referencing fields such as user roles, profiles, or record types?  I've been told that it is and although I can see the value in this for something such as a username that will not change, I'm wondering why it is known as as best practice for something that can change such as user roles.

 

It seems that using the user role id with a note of the present name would be more beneficial since the ID will not change.  For example, if SOQL is writen with a WHERE statement that filters on the UserRole.Name called "Salesperson", and down the road that role name is changed to "Account Executive", won't that cause the SOQL query to return a null value?  Where is if the WHERE statement instead filters on UserRoleId even though the role name has been changed the ID remains the same value thus the SOQL query will still return the expected values.

 

Is this just a preference?  What is the main reason to use names instead of IDs?

 

Thanks

This field reference is not working, not sure why.  Basically it seems that it is assuming the reference field is blank even though it is populated.

 

 

for (Opportunity opp: trigger.new) {
	
	if(opp.CustomUserField__r.UserRoleId=='00E60000000oDgG') {
		//do this
	}
}

 

 

 

Thanks

 

Has anyone had any luck using the Primary_Contact__r field values in formula fields?  They appear to all return null values even though the opportunity has a primary contact.

 

Example:  An opportunity has a primary contact selected but Primary_Contact__r.Id = null.  Would expect Primary_Contact__r.Id to equal the primary contact's Id.

Is it possible to query Multi-Select Picklists to lookup against a Set?  

 

For example:


Instead of this 

SELECT Id, MultiPicklist__c from CustObj__c WHERE MultiPicklist__c includes ('AAA;BBB','CCC')

Can you do something like this?

I get an error when attempting to save this so I'm wondering what the correct syntax, if possible, for something like this would be.

Set<String> singlePicklistSet = new Set<String>();  /*the set of values from a single picklist*/
SELECT Id, MultiPicklist__c from CustObj__c WHERE MultiPicklist__c includes :singlePicklistSet  /*is at least one of the values from MultiPicklist__c in the set of values from the single picklist?*/

Want to create a button that saves the current record, and returns to the current record.  Can this be done using OnClick JavaScript?

 

-Thanks

  • January 17, 2011
  • Like
  • 0

Goal: use a trigger to update a custom field on the Task (OppNumber) with a field on the Opportunity that is selected in the WhatID field (if an Opp is selected)

 

I thought this would be easy to do using a lookup and just passing the value, but you apparently cannot create a lookup on the Activity/Task object. 

 

I know I can pull in the record ID for the opp related via the WhatID field, but how can I refer to a specific field on that record? (Such as the Opportunity Number).

 

Open to suggestions.

 

 

Installed a Twitter Search Widget app that does a search on twitter then displays the results directly inside the Salesforce.com page.  For IE 7.0 users, this is triggering the "Do You Want To Display the Nonsecure Items?" popup.

 

We do not want to disable the popup as it has its uses for other websites but do not want it to be triggered by this Twitter Search Widget?   Is there code we can add to the visualforce page or component that can prevent this?

 

-Thanks

  • September 24, 2009
  • Like
  • 0

How can a scrollbar be entered into this code?

 

 

<apex:page standardController="account"> <c:TwitterSearchWidget search="{!account.Name}" title="Twitter Search Widget results for..." caption="{!account.Name}" loop="true" width="1100" height="500" shellbackground="#8a9ebe" shelltext="#ffffff" tweetbackground="#f3f3ec" tweettext="#000000" links="#8a9ebe" /> </apex:page>

 

 

 

  • September 21, 2009
  • Like
  • 0

Hopefully I'm missing something really simple here. I created a "Home Page Component" with the following body:

 

 

<iframe src="/apex/test" width="100%" frameborder="0" height="100"></iframe>

 

 

Where "test" is my VisualForce page. When I configure this to display on my home page, I see the source code as opposed to my VF page? Any help is greatly appreciated!

 

Regards

How could a custom formula be written to return true if a text field contains an apostrophe?

 

The formula CONTAINS(Title, """) returns this error, Error: Syntax error. Missing ".

 

Any way around this?

 

-Thanks

Hello,

 

Is it possible to write an APEX trigger or S-Control that would merge duplicate records based on certain duplicate rule.

 

For example, is it possible to automatically merge records upon insert or update if a lead's full name and website match that of a contact's full name and contact's account website?

 

-Thanks

Need to return in a view or a  report alll leads or accounts that do not have an open activit. 

 

Want to create a field that returns how many open activities a record has.  Is there a way to this using custom formula field or reports?

 

-Thanks

I am trying to migrate some data from one SF account to another and after failed effort at using the Excel connector moved on to try the APex Data Loader with Data Export data from Account A. WHen I tried to use the Data Loader to insert the Account data object into Account B I was getting 100% "invalid cross reference id" errors. Upon further inspection of the error file I notice some "insufficient access rights on cross-reference id" errors as well. I googled and came across a thread on here that the problem may be related to OWNERID field. So I removed that field form the mapping and near 100% success. Alas I am still getting the "insufficient access rights on cross-reference id" errors. The other error has vanished.

Does anyone have any idea what could be done to resolve this as no one at SF seems to have a clue?
  • May 01, 2008
  • Like
  • 0
Hello,
 
Professional version with API
 
We have a custom button with exec javascript that validates a series of fields based on the user´s role before they can submit the Opp for approval by their Sales Mananger. All the standard validation works great and has been easy to access and program however I cannot figure out how to access the Opportunity Contact Role object from the native options within Salesforce to validate that a Role has been chosen, the Primary has been set, etc . . .
 
Futhermore there is no way create any valildation rules on the Opportunity Contact Role field directly or indirectly. For example if I wanted to create a validation rule on the Stage field that checks to see that the "Primary" contact has been chosen from all the contacts on the Opportunity Contact Role object when the Stage has been set to "Sold" there is no way to query the checkbox value on the "Primary" field.
 
What we want to accomplish is that no Sales Order goes forward without the "roles" of all the Opportunity Contact Roles being define and without a "Primary" chosen from all the contacts.
 
Does anyone have any ideas how this can be done?
 
thanks, crmzepher
Hi,
 
I am trying to get the hour of the 'Date/Time Opened' field within Cases.  Ideally I'd like to be able to pull something like 4:00 PM or 20:00, or something along these lines.
 
Anybody know a way to do this with a formula?
 
Thanks!!

Message Edited by JWOODY on 10-18-2006 09:25 PM

  • October 19, 2006
  • Like
  • 0
From Karina Kaiser @ salesforce:

Because of the limitations on the formula field, this would require creating three fields: “Days Since Closed”, “Days Since Open” and “Age”. Only the “Age” field would be visible on the page layout the others would have to be hidden. 

Formula Fields with Number data type and zero decimal points. Below are the formula values for the fields. 

  1. Days Since Closed  = TODAY() - {!CloseDate}
  2. Days Since Open = NOW() - {!CreatedDate}
  3. Age = IF(ISPICKVAL({!StageName},"Closed Lost"),{!Number_Since_Open__c} -  {!Days_Since_Closed__c},NOW() - {!CreatedDate})
Hopefully this will help you.