• ca_peterson_old
  • NEWBIE
  • 159 Points
  • Member since 2010

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 78
    Replies

 

Hi Everyone,

 

 

I would like to check logged user role with a role of particular record owner. If logged user role is on top of the record owner user role then I would like to show a visualforce page. any idea How to do that it very simply ?

 

Thanks in advance !

Has anyone been able to get jQuery to work in a custom button for a standard page layout?  All the examples I can find are on custom VF pages :(

 

Example code or a link to example code would be very much appreciated.

 

Thank you.

Hi,

May i know how i can access the full page URL into a variable in a component? I am writing a custom apex page which call a custom component. My custom apex page will be called in a framed environment. (Header, left side menu and my Apex page will be in the right side wide frame). On the first load of the page i would like to grab the main url. I have tried the below but they are not addressing my issue. Any help on this is highly appreciated.

 

Page_URL__c= ApexPages.currentPage().getUrl() - This is giving me the custom apex code path (apex/CSP_Tracking) not the main page url which should be https://cs3.salesforce.com/home/home.jsp

 

Page_URL__c = ApexPages.currentPage().getHeaders().get('Host') - This is giving me cs3.salesforce.com but i am interested to get the rest of the URL which is "/home/home.jsp"

 

Thank you,

Sampath

Hello,

 

I am encountering some difficulties to expose my VisualForce tabs in the Force.com sidebar, I did the following:

 

- Created a new Visualforce tab - "Candidates"

 

- Assigned to it a VisualForce Page - "CandidatesPage"  (the page standardController is "Candidate__c")

 

Until here everything went smoothly and I could see the tab displayed properly.

 

When I try to use the sidebar to create new or view recent items of "Candidate' entity I see no  trace of such entity.

 

Why is that ?

 

The "CandidatesPage" code:

 

 

<apex:page tabStyle="Candidate__tab" standardController="Candidate__c" >

<h1>TEST</h1>

</apex:page>

 

 

 

Thanks

Uri

 

 

 

 

 

 

 

 

 

Because I am using a job to update opportunity records every night.  SFDC will automatically put my name on the LastModifiedBy field.  This over writes the user who last touched the record; therefore, I have created a custom field to store the LastModifiedBy value in the custom field prior to updating the record.

 

The problem is that I do not want to put any value in the custom field is the last modified by name is my name or who ever ends up submitting updates of this class code into production and schedules the job.

 

Bottom line, how can I programmatically get the user's name who is running the job/code?

I appreciate your help.

Hi All,

 

I'm trying to copy some custom objects that have a rich text field included in them from a sandbox org back to it's production org. I've tried doing this with the data loader but the images came over as broken links - likewise with copying and pasting the data between orgs.

 

Is there really no way to move the image data over along with the rich text fields? This seems like a major oversight if so.

I've noticed that the usual error handling for the ajax toolkit doesn't work with errors related to session expiration, that is when any error besides a session ID being invalid happens my js displays a nice helpful error message, but if the error is session expiration my onFailure method is never called and wrapping the sforce.apex.execute method in a try/catch block doesn't seem to stop the error from coming to the top.

 

Is there any graceful way to handle session expiration in the ajax toolkit, or am I stuck with the nice long and ugly default session epxiration error?

 

So is anybody else having this issue? When I try and open a file from the SVN history pane I get this error:

 

If I change the editor for apex classes from the force.com IDE editor to the general text editor under Preferences > General > File Associations it loads, but I miss out on all the IDE goodness on all apex class editing across the board.

 

Any ideas on how I can fix this? I have having to use an external app to get access to my SVN history.

 

Using OS X with the standalone eclipse + force.com IDE as a plugin if that helps.

Any ideas?

 

 

I have a protected hierarchical custom setting that my app uses internally, and I'm interested in making it available via a global apex class to be edited outside our namespace, but with the apex class doing validation to ensure the provided values are "safe".

 

I've tried making a global apex class in the same namespace as the protected setting and I get a "permission denied" error when trying to call the class's save method to update the settings. Is there a way to do this?

 

It would make sense that my class in the same namespace as the setting could modify it even if it was initially called by a different namespace, correct?

 

Apex class in the publishing org (that contains the setting):

 

global with sharing class BaseSettings {
	private static BaseSettings instance = null;
	@deprecated global IncidentSettings__c incidentSettings {get; set;} 
	public static boolean isTest = false;
	//Load the default values for the sake of our testing.
	public static void isTest(boolean value){
		isTest = value;
	}
	
	private BaseSettings(){
		if(isTest){
			incidentSettings = new IncidentSettings__c();
		} else {
			initIncidentSettings();
		}
	}
	
	global static BaseSettings getInstance(){
		if(instance == null){
			instance = new BaseSettings();
		}
		return instance;
	}
	
	//Used by the constructor
	private void initIncidentSettings(){
		incidentSettings = IncidentSettings__c.getInstance();
		if(incidentSettings == null){
			incidentSettings = new IncidentSettings__c();
		}
	}

	global void save(){
		upsert incidentSettings;
	}
	
	global boolean getIncidentBlockReopen(){
		return incidentSettings.blockReopen__c;
	}
	global void setIncidentBlockReopen(boolean value){
		incidentSettings.blockReopen__c = value;
	}
	
	global boolean getIncidentOwnerCloseOnly(){
		return incidentSettings.ownerCloseOnly__c;
	}
	global void setIncidentOwnerCloseOnly(boolean value){
		incidentSettings.ownerCloseOnly__c = value;
	}
	
}

 

 

Apex class in the customer org trying to use the settings class:

 

public with sharing class SettingsController {
        public itil_b.Settings baseSettings {get; set;}
        
        public SettingsController(){
                baseSettings = itil_b.Settings.getInstance(); 
        }
        
}

 

And finally the vf page, which works until I hit save, at which point I get a generic "Insufficient Privileges" error.

 

<apex:page controller="SettingsController">
  <apex:form>
      <apex:outputLabel value="Incident Onwer Close Only" />
      <apex:inputCheckbox value="{!baseSettings.incidentOwnerCloseOnly}" />
      
      <apex:commandButton action="{!baseSettings.save}" value="Save" />
  </apex:form>
</apex:page>

 

Any Ideas? 

 

 

I was trying out the inlineEdit attribute on the apex:detial tag and noticed something interesting, it doesn't work correctly on Chrome but does on all other supported browsers.

 

Here's my stupidly simple visualforce page:

<apex:page standardController="itil_b__Incident__c">
    <apex:form >
        <apex:detail subject="{!itil_b__Incident__c}" inlineEdit="true">
        
        
        </apex:detail>
    </apex:form>
</apex:page>

When saving an inline editing action in chrome the buttons on the detail component change to "Saving..." and the data does actually get commited to the record, but the page never changes from "Saving..." back to it's proper state even when the data is comitted. 

 

Trying the same thing in firefox gets the expected results. In chrome's javascript console I see this line I suspect is the issue:

 

Uncaught ReferenceError: sforce is not defined - apex.js:2

 

And for the record all extensions are disabled during this.

 

Bluehawk Networks is hiring a developer to join the existing team on our InSite® IT Service Management application. InSite is built nativley on the Salesforce force.com application platform and is built around the ITILv3 framework.

 

Required Skills:

3+ years of professional software development experience

Experience with object-oriented software development. Java or C# experience is a plus.

Experience with SQL databases and an understanding of database design.

Experience with Salesforce or Force.com administration and development.

 

Preferred Skills:

Experience with SOAP or RESTful webservices.

Knowledge of ITIL, COBIT, or  other IT best practices frameworks.

Experience with SOAP or RESTful webservices.

Experience with Android development is a plus.

 

Ideal candidates would have some background involving IT or system administration experience; knowing the pain and real-world application of service management enables a better understanding of the problems InSite is meant to help solve.

 

Responsiblities include:

Participate in product design and architecture.

Design and build visualforce and javascript user interfaces at a functional level - not including page styling and graphics creation.

Design and build server-side Apex code, sometimes with a need to beexposed to customers and integrators via a stable API.

Authoring unit tests in server-side Apex.

 

We're a startup and certainly have the atmosphere and benefits of one - this position has some flexibility in work hours and does provide the ability to work remotely on a reasonable basis.

This is a full time position with full benefits.

 

This position is located in Campbell, California.

 

Email Chris Peterson at cpeterson@bluehawknetworks.com. Please no recruiters or 3rd parties.

Local applicants preffered but remote applicants will be considered.

So this is stumping me, not my first visualforce component, but I just can't figure out why my save button never calls the saveComment action from the controller.

 

I added a System.asser(false); statement to make it throw an exception no matter what, just to be clear the method is never called.

 

When I press a comment button on a chatter post it renders the comment section as expected, but when I press the save button nothing happens (if I remove the rerender option the page refreshes but does nothing else). No exceptions in the log, and no matter what I should get a failed assertion if the method is ever called.

 

Help?

 

Without further ado, the offending code:

VF Page for a chatter-enabled custom object:

 

<apex:page standardController="itil_b__Incident__c" extensions="ChatterController">
  <apex:form >
  	<c:ChatterBlock subject="{!itil_b__Incident__c}" />
  </apex:form>
</apex:page>

 ChatterBlock component:

 

<apex:component controller="ComponentChatterBlock" allowDML="true" selfClosing="true">
	<apex:attribute name="subject" type="sObject" required="true" assignTo="{!subject}"
		description="The sObject to show a chatter feed for." />
		
	<apex:outputPanel rendered="{!IF(inited = false,'true','false')}">
		{!init}
	</apex:outputPanel>
	
	<!-- Start of Content -->
	
	<apex:outputPanel style="width: 50%; ">
	  <apex:outputPanel rendered="{!feed.posts.size > 0}" id="feedData">
	  <apex:dataTable value="{!feed.posts}" var="post" rules="All" border="2">
	  	<apex:column >
	  		{!post.posterName.name}<br />
	  		at {!post.formatedCreatedDate}
	  	</apex:column>
	  	<apex:column >
	  		<!-- Post body, for text and link posts -->
	  		<apex:outputField rendered="{!IF(post.postType = 'TextPost' || post.postType = 'LinkPost','true','false')}"
	  				value="{!post.fpost.body}" />
	  		<!-- Link URL and title for link posts -->
	  		<apex:outputLink rendered="{!IF(post.postType = 'LinkPost','true','false')}" value="{!post.fpost.LinkURL}">
	  			<br />
	  			<apex:outputField value="{!post.fpost.title}" />
	  		</apex:outputLink>
	  		<!-- Single history post -->
	  		<apex:outputText rendered="{!IF(post.fchanges.size = 1,'true','false')}" value="{!post.firstChange.fieldLabel} changed from {!post.firstChange.oldValue} to {!post.firstChange.newValue}" />
	  		<!-- Multiple History posts -->
	  		<apex:outputPanel rendered="{!IF(post.fchanges.size > 1,'true','false')}">
	  			<ul>
	  			<apex:repeat value="{!post.fchanges}" var="change">
	  				<li>{!change.fieldLabel} changed from 
	  					{!change.oldValue}
	  					to {!change.newValue} </li>
	  			</apex:repeat>
	  			</ul>
	  		</apex:outputPanel>
	  	</apex:column>
	  	<apex:column >
	  		<apex:commandButton value="Comment" rerender="{!$Component.newComment}" action="{!newComment}" >
	  			<apex:param name="commentParentId" value="{!post.postId}" assignTo="{!newComment.parentId}" />
	  		</apex:commandButton>
	  	</apex:column>
	  
	  </apex:dataTable>
	  
	  <apex:outputPanel id="newComment">
   		<apex:pageMessages />
   		CID: {!newComment.FeedItemId}
	   <apex:outputPanel rendered="{!IF(renderComment = true,'true','false')}">
	   	<apex:pageBlock >
	   		<apex:pageBlockButtons >
	   		<apex:commandButton action="{!cancelComment}" value="Cancel" />
	   		<apex:commandButton value="{!saveComment}" value="Save" rerender="feedData"/>
	   		</apex:pageBlockButtons>
	   		<apex:pageBlockSection >
	   			<apex:pageBlockSectionItem >
	   				<apex:inputField value="{!newComment.commentBody}" />
	   			</apex:pageBlockSectionItem>
	   		</apex:pageBlockSection>
	   	</apex:pageBlock>
	   </apex:outputPanel>
   		</apex:outputPanel>
	  
	  </apex:outputPanel>
	  
	  <apex:outputPanel rendered="{!feed.posts.size < 1}">
	  There are no posts for this object.
	  </apex:outputPanel>
   </apex:outputPanel>
   
</apex:component>

 

 

And my page controller:

 

public with sharing class ComponentChatterBlock {
	public boolean inited {get; set;}
	public sObject subject {get; set;}
	public Chatter feed {get; set;}
	public FeedComment newComment {get; set;}
	public boolean renderComment {get; set;}
	
	public ComponentChatterBlock(){
		inited = false;
	}
	
	public void getInit(){
		System.assert(inited == false);
		if(inited == false) {
			feed = new Chatter(subject, true);
			inited = true;
		}
	}
	
	public PageReference newComment(){
		newComment = new FeedComment();
		renderComment = true;
		System.debug('New comment called: '+newComment);
		return null;
	}
	public PageReference cancelComment(){
		System.assert(false);
		newComment = null;
		return null;
	}
	public PageReference saveComment(){
		System.assert(false);
		insert newComment;
		return Page.IncidentDetail;
	}
}

 

 

 

 

Hi All,

 

As salesforce doesn't seem to have an offical bug tracker or bug reporting system I don't know where else to post this.

I've found and duplicated a number of times an issue when using SOSL with an implied namespace the search fails silently.

 

For example, assuing a namespace of tst, this query would properly search:

 

List<List<SObject>> searchList = [FIND :searchText IN ALL FIELDS RETURNING
            tst__customObj__c(id, LastModifiedDate, name, tst__Description__c, tst__Status__c, tst__Subject__c, tst__Type__c, RecordType.name)];

 

While this query would properly compile, and run without exception, but always return no results, even if there are valid matches:

 

List<List<SObject>> searchList = [FIND :searchText IN ALL FIELDS RETURNING
            customObj__c(id, LastModifiedDate, name, tst__Description__c, tst__Status__c, tst__Subject__c, tst__Type__c, RecordType.name)];

 

This differs from SOQL, and as the later bugged example compiles this behavior is clearly not intended. As SOSL is already poorly documented and tricky to use this additional barrier to entry

 

Hi All,

 

I have a rather complex visualforce component that has a strange quirk in the search area, when the user types some text into an apex:inputText component and presses the search button next to it the value is passed properly into apex and acted upon, but when the componenet rerenders the field is blank.

 

Here's some screenshots showing the problem:

 

I click search:

 

At this point if somebody wants to refine their search they have to type the whole term again, and if they walk away and come back they have no way of telling their last search term, all around bad usability. Help?!

Component code:

 

<apex:component controller="ComponentCIPicker" selfClosing="true">
    <apex:attribute name="CIs" required="true" type="namespace__CI__c[]" assignTo="{!CIList}"
        description="A list of CIs to populate. If non-empty these CIs will start selected" />
    <apex:attribute name="initialSearch" required="false" type="String" assignTo="{!searchText}" default=""
        description="The initial search term for the CI search. If not set no CIs will be shown until the user enters a search term" />
    <apex:attribute name="includeLookup" required="false" type="boolean" default="false"
        description="Include a lookup field for manually selecting CIs, generally useful to using recent items" />
    <apex:attribute name="title" required="false" type="String"
        description="PageBlock title" />
    <!-- Features to add: button to show CIs from same Account/Contact specified-->
        
    
    
<apex:outputPanel id="wholeComponent">
<apex:actionRegion >
    <apex:pageBlock id="block" title="{!title}">
            <apex:commandButton value="startSearch" action="{!doSearch}" rerender="wholeComponent" status="LoadStatus" style="display: none"/>
            <apex:actionFunction name="startSearch" action="{!doSearch}" rerender="wholeComponent" status="LoadStatus"/>
            <apex:outputLabel value="Search for CIs: "/>
            <apex:inputText value="{!searchText}" id="sstext" />
            <apex:commandButton value="Search" action="{!doSearch}" rerender="wholeComponent" status="LoadStatus"/>
            <apex:actionStatus id="LoadStatus">
                <apex:facet name="start"><apex:image url="{!URLFOR($Resource.icons,'/loading.gif')}" /></apex:facet>
            </apex:actionStatus>
            <apex:actionRegion >
            <apex:outputPanel rendered="{!IF(includeLookup = true,true,false)}" style="align: right;" id="lookup">
                <apex:outputLabel value=" Browse Recent CIs " />
                <apex:inputField value="{!inputCI.namespace__CI__c}" required="false"/>
                <apex:commandButton value="Add" action="{!addInputCI}" rerender="wholeComponent" />
            </apex:outputPanel>
            </apex:actionRegion>
        
        <apex:outputPanel id="assetTable" >
                
                <apex:pageMessages />
                <apex:pageBlockTable value="{!currentSelection}" var="asset" rules="rows" cellpadding="5" cellspacing="2" width="1024"
                    columnsWidth="30px, 200px, 600px, 200px, 100px" >
                    <apex:column >
                        <apex:inputCheckbox value="{!asset.Selected}"/>
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header">
                            <apex:outputLabel value="Name" />
                        </apex:facet>
                        <apex:outputField value="{!asset.asset.Name}"/>
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header">
                            <apex:outputLabel value="Description" />
                        </apex:facet>
                        <apex:outputField value="{!asset.asset.namespace__Description__c}"/>
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header">
                            <apex:outputLabel value="Type" />
                        </apex:facet>
                        <apex:outputField value="{!asset.asset.namespace__Type__c}"/>
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header">
                            <apex:outputLabel value="Status" />
                        </apex:facet>
                        <apex:outputField value="{!asset.asset.namespace__Status__c}"/>
                    </apex:column>
                </apex:pageBlockTable>

                <apex:pageblockSection rendered="{!IF(currentSelection.size > 0, 'false', 'true')}">
                    <apex:outputText value="There are no CIs available for association" />
                </apex:pageblockSection>
                <apex:commandButton value="Add Selected" action="{!addSelected}" rerender="assetTable,selected"/>

            </apex:outputPanel>
        
            
            
            <apex:pageBlockButtons location="bottom">
                
            </apex:pageBlockButtons>
        </apex:pageBlock>
        
        <apex:pageBlock title="Selected CIs" id="selected">
            <apex:pageBlockTable value="{!CIList}" var="ci">
                <apex:column >
                        <apex:facet name="header">
                            <apex:outputLabel value="Name" />
                        </apex:facet>
                        <apex:commandLink action="{!unselect}" immediate="true" rerender="selected">
                            <apex:param name="unselectId" value="{!ci.id}" assignTo="{!toUnselect}"/>
                            <apex:image value="{!URLFOR($Resource.icons,'/woo/close_16.png')}" title="Remove from selection"/>
                        </apex:commandLink><apex:outputField value="{!ci.Name}"/>
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header">
                            <apex:outputLabel value="Description" />
                        </apex:facet>
                        <apex:outputField value="{!ci.namespace__Description__c}"/>
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header">
                            <apex:outputLabel value="Type" />
                        </apex:facet>
                        <apex:outputField value="{!ci.namespace__Type__c}"/>
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header">
                            <apex:outputLabel value="Status" />
                        </apex:facet>
                        <apex:outputField value="{!ci.namespace__Status__c}"/>
                    </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
        </apex:actionRegion>
    </apex:outputPanel>
</apex:component>

 

Relevant apex:

public with sharing class ComponentCIPicker {
public List<namespace.AssetWrapper> currentSelection {get; set;}
public List<namespace__CI__c> CIList {get; set;}
public namespace__CIRel__c inputCI {get; set;}
public id toUnselect {get; set;}

public String searchText {get; set{
        searchText = value;
        doSearch();
        }
    }
public ComponentCIPicker(){ currentSelection = new List<namespace.AssetWrapper>(); inputCI = new namespace__CIRel__c(); if(searchText != null){ doSearch(); //for the initialSearch attribute to function } } public void doSearch(){ try{ currentSelection = namespace.AssetWrapper.wrapAssets( doSearch(searchText) ); }catch(exception e){ System.debug('Invalid search: '+e); } } private static List<namespace__CI__c> doSearch(String searchText){ List<namespace__CI__c> Assets = new List<namespace__CI__c>(); if(searchText.length() <= 2){ //throw exception } List<List<SObject>> searchList = [FIND :searchText IN ALL FIELDS RETURNING namespace__CI__c(id, LastModifiedDate, name, namespace__Type__c, namespace__Asset_No__c, namespace__Status__c, namespace__Description__c, namespace__Serial_Number__c)]; Assets = ((List<namespace__CI__c>)searchList[0]); return Assets; }

 

 

First of all, good work on adding XSRF (cross-site request forgery) to the security scanner.

 

Secondly, I'd like to ask for some tips on a more secure way of doing things.

 

Currently I have a button for a ticketing system that most compeditors have, one that takes ownership of the current record. Currently I have this implemnted as a visualforce page something like this:

 

 

<apex:page standardController="ticket__c" extensions="sObjectUtils" action="{!takeOwnership}">
<apex:outputPanel rendered="false">
<!-- here to let the standardController.getRecord() method rather than SOQL -->
	{!ticket__c.ownerId}
</apex:outputPanel>

Ownership taken.
</apex:page>

 

The problem is I can't see a way to put a button on a detail page that doesn't open me up to XSRF without requiring an exta step. I'd love it if I could call an action with a button directly, which would mitigate the XSRF issues, but that's currently not supported by the platfrom.

 

So mighty security gurus, what's the "proper" way of implementing this button?

 

I've done some development of apex that reads and processes the custom object field history tables and produces that amounts to a cusotmized history related list.

 

That's all well and good, except that it seems that the apex test runner does not track field history, and the oldValue and newValue fields on the history object are not writable.

 

It's a large apex class and has taken the total coverage for my app below 75%. How can I properly test in this situation? Help salesforce!

I have an Apex method that is marked as a remoteAction which is attempting to take two parameters: a Lead and a List of custom objects ("Custom_Object__c" isn't the real object's name, just changed to protect the innocent);

 

@RemoteAction
public static Boolean insertData(Lead l, List<Custom_Object__c> customObjects) {
   // insert the Lead
   insert l;
   // assign the lead Id to each custom object in the list
   for(Custom_Object__c c : customObjects) {
      c.Lead__c = l.Id
   }
   // insert the custom objects
   insert customObjects;
   // return true (just for example)
   return true;
}

 Over in Javascript, I'm calling this remoteAction with the following data:

// sample data
var lead = {
   FirstName = 'Test',
   LastName = 'Test',
   Company = 'Test',
   Email = 'test@test.com',
   Phone = '555 555 1212'
};
var customObjects = [
   {
      Custom_Field1__c = 'A',
      Custom_Field2__c = 'B'
   },
   {
      Custom_Field1__c = 'A',
      Custom_Field2__c = 'B'
   }
];
MyApexClass.insertData(lead, customObjects, function(result, event) {
   // this would be the callback mojo
});

This code will make it as far as the insertData method, but I get the following error:

 

Visualforce Remoting Exception: undefined

 

I tried changing the insertData method to take the second parameters as List<sObject> instead of List<Custom_Object__c> (and modded the code to use dynamic DML to support this), but then I get this error:

 

Visualforce Remoting Exception: Unable to determine SObject type: SObject.  Please provide an 'id' or 'sobjectType' value.

 

I interpret this error as needing to supply a 'sobjectType' property to either a) the elements in my "customObjects" array or b) the array itself. I've tried all of the following permutations but still get the same error:

 

// ... add the property to the element doesn't work
var customObjects = [
   {
      Custom_Field1__c = 'A',
      Custom_Field2__c = 'B',
      sobjectType = 'Custom_Object__c'
   },
   {
      Custom_Field1__c = 'A',
      Custom_Field2__c = 'B',
      sobjectType = 'Custom_Object__c'
   }
];

// add the property to the array doesn't work customObjects.sobjectType = 'Custom_Object__c'; // for fun, tried to indicate that it's a list, these don't work either customObjects.sobjectType = 'List<Custom_Object__c>'; customObjects.sobjectType = 'Custom_Object__c[]';

 

Can someone point me in the right direction here? Is there another way to specify the sobjectType property? Are there issues with multiple params on a remoteaction, or issues with collection-based params? 

I'm curious what is the best way to login and authenticate users for Apex methods exposed as web services. Should the user just login with the partner or enterprise wsdl login operations?

 

The problem I see with this approach is the serverURL retruned with these login operations is something like: https://cs2-api.salesforce.com/services/Soap/u/23.0/00DR0000000GHhW .

 

Yet the URL in the wsdl for my Apex web service is something like this: https://cs2-api.salesforce.com/services/Soap/class/ClassName. 

 

Unless I am missing something you have to eithe...

A) hardcode the apex url or

B) Extract the base URL returned form the login response so you get the right instance and then store and append the relative Apex part of the url.

 

Thoughts? Insights?

 

I'm thinking of creating an idea so that wsdls created from Apex methods also have some basic operations like login.

 

Thanks,

Jason

  • December 20, 2011
  • Like
  • 0

Hi All,

 

I'm trying to copy some custom objects that have a rich text field included in them from a sandbox org back to it's production org. I've tried doing this with the data loader but the images came over as broken links - likewise with copying and pasting the data between orgs.

 

Is there really no way to move the image data over along with the rich text fields? This seems like a major oversight if so.

 

Hi Everyone,

 

 

I would like to check logged user role with a role of particular record owner. If logged user role is on top of the record owner user role then I would like to show a visualforce page. any idea How to do that it very simply ?

 

Thanks in advance !

Hi Guys,

 

I have two objects Target List and Selling Area. Also have Target List Member object as junction of both. User can create target list and add selling area based on some search criteria. I am storing that SOQL in query field of Target List. Overnight batch to run through all target list get the query and iterate over query result and insert Target List Member records. But Batch class gives me Too Many DML rows error while insertion.

 

I am testing this with 4 target lists Each of them have separate query. These quries return 2764 records of selling area. Means 2764*4 target list members.  Now requirement is one target list can have up to 50K-80K selling area, so setting scope to 1 won't solve my problem. Any suggestion or workaround?

 

Thanks,

Ankur

 

Hi All, i am getting some problem about licence management..Let me explain you. Suppose i have created A managed package(Which Contains my App say "Recruiting").i have installed LMA in my sales org,and listed my App in Appexchange.. Now Subscriber can install my App.... and all the things(like how many no. of licencses he is using) we can track through LMA.. Now if i have given him 10 licenses to subscribber..and if for our App subscribers Admin is using 5 customer portal licese and 5 salesforce platform.... and i want to charge for my App according to licese he has..(say 100$ for salesforce platform and 50$ for customer portal license).... can i do this??? How?

 

Hi,

 

I want to know if we have multiple user profiles set in the org. Then can we get counts by user types in LMA.

 

For e.g. I sell the product with 10 licenses. I create two user types...Type 1and Type 2. I create 3 Type 1 users and 4 Type 2 users manually from Admin profile. Then in LMA can I get the count separately? 

 

 

Regards,

Devendra S

Hello All,

I 'd an issue regarding sending emails using singleemailmessage class. Heard that we can send 10 * 1000 = 10000 emails per execution (10 arrays, each array to accomodate 1000 emails). Is this true?

But i am unable to send more than 10 emails. Could anyone plz clarify me how to do. PFB my code snippet:

 

            }

for(Permit__c p:permitList){
                 Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); 
                                    String subject = p.Name+' | '+p.Region__c+' | '+p.Full_State__c+' | '+p.Channel__c+' | Status=Expired';
                                    email.setSubject(subject);
                                    String emailadd = 'abc@xyz.com';
                                    String[] toAddresses = emailadd.split(',');
                                    email.setToAddresses(toAddresses);
                                    email.setHTMLBody( 'email body.' );
                 Messaging.SendEmailResult[] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email}); 

 

 

An error is being thrown when 10 mails are sent and is about to send 11th email.

Plz help!

Has anyone been able to get jQuery to work in a custom button for a standard page layout?  All the examples I can find are on custom VF pages :(

 

Example code or a link to example code would be very much appreciated.

 

Thank you.

Hey guys-

I need to create a trigger on the account object that does the following:

  • Look at the Account Owner’s User Record
  • Look at the “Region” field on the User Record
  • Update the “Apex Region” field on the Account Object based on the Region value from the User’s Record

 

I have a similar trigger that works perfectly for a text field, but I would like to set this up as a picklist (for easier reporting).

 

Here’s the code that I'm trying (it complies but doesn't update the picklist)-

 

 

trigger ApexTestTrigger on Account (before insert, before update) {

// create a set of all the unique ownerIds  
       Set<Id> ownerIds = new Set<Id>();  
       for (Account a : Trigger.new)  
           ownerIds.add(a.OwnerId);      
     
    // query for all the User records for the unique userIds in the records  
       // create a map for a lookup / hash table for the user info  
       Map<Id, User> owners = new Map<Id, User>([Select Region__c from User Where Id in 
       :ownerIds]);     
     
       // iterate over the list of records being processed in the trigger and  
      // set the Region before being inserted or updated  
      for (Account a : Trigger.new)  
           a.Apex_Region__c = owners.get(a.OwnerId).Region__c;   
}

 Help would be greatly appreciated!

 

  • May 25, 2011
  • Like
  • 0

Dear All,

 

I have been involved in a rather frustrating email exchange with Salesforce support (both partner and 'premier' support) but I simply cannot believe what they are saying is true.

 

We signed up for our first development org in October 2007 where we started to build a managed package to manage our support cases, timesheets and invoicing for our Unlimited Edition instance.  I contacted my Salesforce account manager at the end of March 2011 and asked him to enable Entitlements in our live Unlimited Edition org.  At the same time I contacted Salesforce support and asked them to enable Entitlements in our Developer Edition org so that we could integrate the Entitlements functionality into our managed package.  This was the response I received:

 

 

Developer Edition (DE) orgs created before this feature was made available (164 release, which was after your dev org was created) will not have this feature enabled.  Anyone wanting to use this feature in a DE org, should sign-up for a new DE org on the page below: (link to sign up page)

Huh?  So what Salesforce are saying is that any developer who has an older org (i.e who has been a Salesforce customer for longer) will not get access to any new Salesforce.com functionality.   If a developer wants to get access to the new functionality and ultimately help increase Salesforce.com's revenues they need to create a new package and migrate all of their customers' data from the old objects in to the new objects?  Seems slightly odd and very counter productive!  I can't imagine if likes of BMC / DreamFactory / Vertical Response have Developer Edition instances on NA5 that they would have been given the same response!

 

I decided to contact my account manager to see whether this response was just due to a momentary lapse on the part of the support rep, as I couldn't beleive it was true!  Apparently it is.  Salesforce will not enable new functionality in old developer edition orgs!  If this is true, then it does pose an interesting question.  Are the Developer Edition orgs the same as the live ones?  Surely in the world of SAAS and after a major upgrade by the hosting provider everyone should be on the same version of the 'software'?

 

Has anyone else come across this issue?  If so, how did you fix it?  I know that Salesforce do support behind the scenes migration of development orgs as we have recently had a publishing org migrated from NA7 to NA10, so I know that it can be done, but I do not understand why it hasn't been offered!

 

Please can anyone help?

 

Salesforce, is anyone able to put right what seems like a very simply administrative mistake and get our org moved or updated so we can integrate entitlements into our business processes!

There is a custom picklist field (payment__c) in Account, same as in Quote

 

Ok, if one people create an Account (also select one payment in it), and then create one opportunity, and then click 'add new Quote', the payment__c will be got automatically before save the quote (because it's same as Account's payment__C).

 

Is it possible? Anyone can tell me how to do it? Or will one trigger?

 

Thanks.

I have a trigger on a custom object which depending on some criteria; it is supposed to create a list of emails to send.  I have created the trigger and it works fine.  Code coverage is 100%.  I’m ready to deploy it to production.

 

I’m calling a future method to process the records asynchronously.  I was expecting to be able to pass a list of account Ids created from my 2000 records to the future method to process but the trigger gives me 200 records at a time.  By the time the test method is done running, I’m very close to the limit of Number of future calls I can make.  What I really wanted and expected was for the future method to be called once and for all the processing to happen there.

 

Why does the trigger or apex automatically break up the 2000 records into bunches of 200 and process them separately? 

 

10:18:45.395|METHOD_EXIT|[7]|testAWAfterInsert

10:18:45.395|METHOD_ENTRY|[69]|System.debug(ANY)

10:18:45.395|USER_DEBUG|[69]|DEBUG|********** TEST 5 **********

10:18:47.357|METHOD_EXIT|[84]|system.Test.startTest()

10:18:47.358|DML_BEGIN|[85]|Op:Insert|Type:Actuals_Weekly__c|Rows:2000

10:18:48.160|USER_DEBUG|[19]|DEBUG|********** newAWs.size = 200

Number of future calls: 1 out of 10

...

10:18:55.859|USER_DEBUG|[19]|DEBUG|********** newAWs.size = 200

Number of future calls: 10 out of 10 ******* CLOSE TO LIMIT

 

Here is my trigger:

trigger AWTriggers on Actuals_Weekly__c (after delete, after insert, after undelete,after update,

                                         before delete, before insert, before update) {

   

    if(trigger.isAfter){

                      if(trigger.isInsert){

                                              AWAfterInsert myAfterInsert = new AWAfterInsert(Trigger.new);

                        }

                        if(trigger.isUpdate){}

                        if(trigger.isDelete){}

                        if(trigger.isUndelete){}

    }

   

    if(trigger.isBefore){

                        if(trigger.isDelete){}

                        if(trigger.isInsert){}

                        if(trigger.isUpdate){}

    }

}

Here is my class:

public with sharing class AWAfterInsert {

 

                        public AWAfterInsert(Actuals_Weekly__c[] newAWs){

                                                NotOrderedMGA14(newAWs);

                        }

                        public static void NotOrderedMGA14(Actuals_Weekly__c[] newAWs){

                                                System.debug('********** newAWs.size = ' + newAWs.size());

                                               

                                                Set<Id> accountIds = new Set<Id>();

                                                for(Actuals_Weekly__c aw : newAWs){

                                                                        accountIds.add(aw.Account__c);

                                                }

 

                                                AWGlobalUtils.asyncNotOrderedMGA14(accountIds);

                        }

}

Here is my future method:

global class AWGlobalUtils {

 @future public static void asyncNotOrderedMGA14(Set<Id> accountIds){

  System.debug('****************************** accountIds.size = ' + accountIds.size());

  list<Actuals_Weekly__c> awl = Database.query('Select Id, Procedure__c, Read_Date__c, Account__c, Account__r.Name, Account__r.OwnerId From Actuals_Weekly__c Where Procedure__c = \'MOLECULAR GRADING ASSAY\' And Read_Date__c < ' + getTargetDate() + ' And Account__c in : accountIds');

  System.debug('********** awl.size = ' + awl.size());

  Map<Id,Actuals_Weekly__c> am = new Map<Id,Actuals_Weekly__c>();

  if(!awl.isEmpty()) {

   for(Actuals_Weekly__c aw2 : awl){

    am.put(aw2.Account__c,aw2);

   }

  }

  System.debug('********** am.size = ' + am.size());

  // Send an email to each account owner

  list<Messaging.SingleEmailMessage> el = new list<Messaging.SingleEmailMessage>();

  for(Actuals_Weekly__c aw3 : am.values()){

   Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

   mail.setTargetObjectId(aw3.Account__r.OwnerId);

   mail.setSaveAsActivity(false);

   mail.setPlainTextBody('Your account: ' + aw3.Account__r.Name +' has not ordered MGA in the past 14 days.');

   mail.setHtmlBody('Your account:<b> ' + aw3.Account__r.Name +' </b>has not ordered MGA in the past 14 days.<p>'+

   ' To view the account <a href=https://cs1.salesforce.com/' + aw3.Account__r.Id + '>click here</a>');

   el.add(mail);

  }

  System.debug('********** el.size = ' + el.size());

  if(!el.isEmpty()){

   Messaging.sendEmail(el);

  }

 }

}

Here is my test method:

@isTest

private class testAWAfterInsert {

 static testMethod void AccountHasOrderedBulkTesting2(){

   System.debug('********** TEST 5 **********');

   List<Account> testAL = new List<Account>();

   for(integer i=0; i<200; i++){

    testAL.add(new Account(Name = 'Test Account ' + i, Account_Classification__c = 'Doctor'));

   }

   insert testAL;

   Date d2 = date.newinstance(2011, 1, 17);

   List<Actuals_Weekly__c> testAWL2 = new List<Actuals_Weekly__c>();

   for(Account a : testAL){

    for(integer i=0; i<10; i++){

     testAWL2.add(new Actuals_Weekly__c(Account__c = a.Id, Read_Date__c = d2, Procedure__c = 'MOLECULAR GRADING ASSAY'));

    }

   }

   test.startTest();

   insert testAWL2;

   test.stopTest();

 }

} 

  • March 30, 2011
  • Like
  • 0

Hi

 

I've  a custom field in a custom object. I'm posting an xml file through external API. It is posted successfully. Now I want to map that data into Contact Object. I'm facing too many Script statements.

 

My code is:

 

 

trigger dmldata on CnPData__c (before insert,after insert) {
String dataxml;
    for(CnP__CnPData__c cpdata:Trigger.new){
         dataxml=cpdata.CnP__DataXML__c;
    }
    System.debug('hiiiiiiiii'+dataxml);
    XmlStreamReader reader= new XmlStreamReader(dataxml);
    System.debug('reader valueeee'+reader);
    while(reader.hasNext()) {
    System.debug('reader event nameee'+reader.getEventType());
     /*if (reader.getEventType() == XmlTag.START_DOCUMENT) {
     System.debug('local nameee'+reader.getLocalName());
    
}*/
}
 
}
My sample xml in the field is :
<?xml version="1.0" encoding="utf-8"?>
<Contact>
 <FirstName>anu</FirstName>
    <LastName>rrr</LastName>  
 </Contact>
One more, If I debug the reader.getEventType() it is showing the Start_Document. I want this value as START_ELEMENT. how can I get that?
If it START_DOCUMENT how can I proceed with that to read the values.
Thanks a ton in advance.

 

Is it possible not to render apex:component in SPAN,  just let it rendered whatever I've coded

I have an Apex Class that is Schedulable.  What is the proper way to package this class so that when a user installs it into their org it automatically schedules the class to run?

  • March 02, 2011
  • Like
  • 0

I am playing with the translation workbench and a managed package.

 

It seems that you cannot rename the "Tab Name" and "Display Name" for a custom object when you install the package in an org where the translation workbench is enabled.

 

It works for any other field but not this one, the edit link is not displayed.

 

Is there a reason for this or did I miss something ?

 

Thanks