• NMackey
  • NEWBIE
  • 25 Points
  • Member since 2010

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 13
    Replies

I'm working on a managed package that I have uploaded as a released package to the AppExchange, but not yet submitted it for approval as I'm waiting on Salesforce Parner access.

 

I have since discovered a data validation issue related to the lenght of a field in a custom object, but cannot change the length of the field at all.

 

How can I get around this? I've tried uploading a new managed beta package, but the field length is still uneditable. I can't see any way to deprecate or delete the managed released package I have uploaded either.

  • September 02, 2011
  • Like
  • 0

I've got a VF page that displays data from a few custom sObjects and have command buttons to create new objects using the following code.

 

 

<apex:commandButton action="{!URLFor($Action.Currency_Pair__c.New)}" value="New Currency Pair" />

 The problem with this code is it automatically generated a RetUrl paramater bringing users back to the VF page without showing them the saved record as is default behavior in the Salesforce UI. 

 

How do can I specify no RetUrl here?

 

 

I'm having a look at REST and logging in via OAuth 2.0 client side flow and running into problems making a web request once I'm authenticated.

 

I don't think it's the actual auth because it's working fine on an iPhone application (Using traditional SOAP API) and the refresh and access tokens I'm getting match when I do from that app if I use the same client key.

 

My code is this:

 

 

void LoggedIn(object o, LoginEventArgs e)
{
    System.Diagnostics.Trace.WriteLine(e);

    string url = e.InstanceUrl + "/services/data/v20.0/sobjects/";

    WebRequest request = WebRequest.Create(url);
    request.Headers.Add("Authorization:OAuth " + e.AccessToken);
           
    WebResponse response = request.GetResponse();
    // 403 Error!
}

 

Am I missing something? 

 

Update:

 

I used the returned token via cUrl and got the following response:

 

 

[ {
  "message" : "Session expired or invalid",
  "errorCode" : "INVALID_SESSION_ID"
} 

 

This is weird, should I be setting up a session cookie instead of adding an Authorization header?

 

I am trying to conditionally assign a value to an apex variable to try and reduce the level of tag soup I'm experiencing writing VF pages to display statements and invoices but running into problems that is making me just move impossible to read and maintain markup elsewhere in my page.

 

I tried using this, so I could refer to fields of the variable 'account' wherever I like. Eclipse gives me message saying 'error' with no text.

 

 

<apex:variable var="account" value="{!IF(CustomObject__c.RecordType.DeveloperName == 'Something', CustomObject__c.Bank_Account__r, CustomObject__c.Other_Bank_Account__r)}" />

 

 

What does work is this:

 

 

<apex:variable var="accountName" value="{!IF(CustomObject__c.RecordType.DeveloperName == 'Something', CustomObject__c.Bank_Account__r.Name, Deal__c.Other_Bank_Account__r.Name)}" />
<apex:variable var="accountSomeOtherField" value="{!IF(CustomObject__c.RecordType.DeveloperName == 'Something', CustomObject__c.Bank_Account__r.someOtherField, CustomObject__c.Other_Bank_Account__r.SomeOtherField)}" />

 

 

But if I have to define a variable like this for every single field, it starts to defeat the purpose!

 

Am I doing it wrong? Any alternate suggestions?

I have a VF page that groups together lists of custom objects that the user can click on top open the page for that custom object but I have just noticed that the breadcrumb link is the last standard visualforce page I clicked on, not my custom page.

 

Can I set this programatically?

i'm trying to make a custom page to print a confirmation document of sorts and using my own stylesheet to do it.

 

I have uploaded a zip file containing confirmation_style.css and logo.jpg as a static resource called 'confirm' and am accessing my custom page via a custom button. 

 

The code I'm using inside the head tag of my page is:

 

 

<apex:stylesheet value="{!URLFOR($Resource.confirm, 'confirmation_style.css')}" />

 

 

But the rendered page is totally unstyled. A similar problem exists when trying to retrieve logo.jpg.

 

If I view the source of the page and try pasting the generated URL, I just get a page containing literally nothing. But then if I enter an arbitrary file name, I get the same result.

 

Am I missing some sort of permissions thing here? Can anyone give me some pointers?

 

I'm developing an application that contains multiple custom objects whose records function as more or less static data that is looked up in another custom object by the user.

 

I'm talking accounts, currencies etc except there are around 10 custom objects in all.

 

I want to have a single page that lets me select the custom object type from a drop down and display something similar to the default controller's list view.

 

So far, I've just been showing and hiding blocks of html to achieve this result but it's not really an ideal way of doing this in terms of code reuse. Is there any more generic way I can display info about multiple custom objects on a single page?

Is it possible to set the RecordType field for an object by name via the data loader?

 

At present, I just obtain a copy of the RecordType IDs and use a VLOOKUP in Excel to map them prior to import which might end up being a problem for end users.

 

I was thinking of having an additional custom field that gets updated with the record type name via a trigger prior to inset and update. That's another SOQL query though, and while I'm not close to hitting governer limits now, that may change in the future as we add functionality.

 

If the answer to my question below is negative, which is my suggested solutions should I go for?

I'm working on a managed package that I have uploaded as a released package to the AppExchange, but not yet submitted it for approval as I'm waiting on Salesforce Parner access.

 

I have since discovered a data validation issue related to the lenght of a field in a custom object, but cannot change the length of the field at all.

 

How can I get around this? I've tried uploading a new managed beta package, but the field length is still uneditable. I can't see any way to deprecate or delete the managed released package I have uploaded either.

  • September 02, 2011
  • Like
  • 0

I've got a VF page that displays data from a few custom sObjects and have command buttons to create new objects using the following code.

 

 

<apex:commandButton action="{!URLFor($Action.Currency_Pair__c.New)}" value="New Currency Pair" />

 The problem with this code is it automatically generated a RetUrl paramater bringing users back to the VF page without showing them the saved record as is default behavior in the Salesforce UI. 

 

How do can I specify no RetUrl here?

 

 

I'm having a look at REST and logging in via OAuth 2.0 client side flow and running into problems making a web request once I'm authenticated.

 

I don't think it's the actual auth because it's working fine on an iPhone application (Using traditional SOAP API) and the refresh and access tokens I'm getting match when I do from that app if I use the same client key.

 

My code is this:

 

 

void LoggedIn(object o, LoginEventArgs e)
{
    System.Diagnostics.Trace.WriteLine(e);

    string url = e.InstanceUrl + "/services/data/v20.0/sobjects/";

    WebRequest request = WebRequest.Create(url);
    request.Headers.Add("Authorization:OAuth " + e.AccessToken);
           
    WebResponse response = request.GetResponse();
    // 403 Error!
}

 

Am I missing something? 

 

Update:

 

I used the returned token via cUrl and got the following response:

 

 

[ {
  "message" : "Session expired or invalid",
  "errorCode" : "INVALID_SESSION_ID"
} 

 

This is weird, should I be setting up a session cookie instead of adding an Authorization header?

 

Hello,

 

I am a newbie Apex Developer trying to solve an issue with calling the StandardController.edit() method.

 

I created a custom Organization__c object for a user to enter info about their company.   I want logic in the class to limit t 1 instance of Organization__c, so I over-rode the "New" button on the object to point to a Visualforce page that calls my determinePageRedirect method.  If the list of Organization__c is > 0, it returns a PageReference to the edit page using the current ID.  If the list is null, I want to call StandardController.edit() to show the regular new page for Organization__c.  

 

Code works as expected when this.existingOrganization.size () > 0. however, I get an error message "cannot call edit() on null object when that list is empty. Seems like I need some mojo on my StandardController instantiation to make this work. Any ideas? Any help is greatly appreciated - this is driving me nuts!

 

Thanks

 

Apex Class

 

public class OrganizationValidation {

	//declare a private controller variable
	private ApexPages.StandardController controller;
	
	private Organization__c org {get;set;}
	
	//populate list of existingOrganizations
	public List<Organization__c> existingOrganizations;
		public List<Organization__c> getExistingOrganizations(){
			return existingOrganizations;	
	}

	//instatiate class
	public OrganizationValidation(){	
	}
	
	//standard controller constructor
	public OrganizationValidation(ApexPages.StandardController pController) {
        this.controller = pController;
        System.debug('***this.controller: ' +this.controller);
		
		//need StandardController to be aware of current context
		
		
		this.org = (Organization__c)pController.getRecord();
		System.debug('***org: '+ org);

    	OrganizationRedirect();
    }
    
	//Run these methods when we hit the Visualforce page
	public PageReference OrganizationRedirect(){
		
			
		//invoke method to query if there is an Organization__c result
		queryOrganizations();
		
		//invoke method to redirect based on if/then
		determinePageRedirect();
		
		return null;
	
	}
	
	//PageReference method – button on Visualforce page calls
	public PageReference editButtonRedirect() {

		PageReference editRedirect;
		for(Organization__c org: this.existingOrganizations){
				Organization__c myOrg = org;
				editRedirect = new PageReference ('/' + myOrg.id + '/e');
		
		}
	
		return editRedirect;
	
	}
		
	public void queryOrganizations(){
		//query the orgID
		this.existingOrganizations = [Select id, Name From Organization__c];
		//System debug
		System.debug('***existingOrganizations: '+existingOrganizations);
		
	}
	
	//Method to run if/else statement to redirect page
	public PageReference determinePageRedirect(){
	
		PageReference redirectPage;
		if (this.existingOrganizations.size() > 0){
			
			redirectPage = new PageReference ('apex/OrganizationRedirect');
			
		}else{
			
			//Show new page
			redirectPage = this.controller.edit();
			
		}
	
return redirectPage;
	
	}
}

 

Visualforce Page

 

<apex:page standardController="Organization__c" extensions="OrganizationValidation" action="{!determinePageRedirect}">
	<apex:outputPanel >
		<apex:form >
			<h1>Warning</h1>
			<p>You already entered your Organization's information.  Please edit the existing record.</p>
			<apex:commandButton action="{!editButtonRedirect}" value="Edit Organization" />
		</apex:form>
	</apex:outputPanel>
</apex:page>

 

 

 

 

 

i'm trying to make a custom page to print a confirmation document of sorts and using my own stylesheet to do it.

 

I have uploaded a zip file containing confirmation_style.css and logo.jpg as a static resource called 'confirm' and am accessing my custom page via a custom button. 

 

The code I'm using inside the head tag of my page is:

 

 

<apex:stylesheet value="{!URLFOR($Resource.confirm, 'confirmation_style.css')}" />

 

 

But the rendered page is totally unstyled. A similar problem exists when trying to retrieve logo.jpg.

 

If I view the source of the page and try pasting the generated URL, I just get a page containing literally nothing. But then if I enter an arbitrary file name, I get the same result.

 

Am I missing some sort of permissions thing here? Can anyone give me some pointers?

 

I'm developing an application that contains multiple custom objects whose records function as more or less static data that is looked up in another custom object by the user.

 

I'm talking accounts, currencies etc except there are around 10 custom objects in all.

 

I want to have a single page that lets me select the custom object type from a drop down and display something similar to the default controller's list view.

 

So far, I've just been showing and hiding blocks of html to achieve this result but it's not really an ideal way of doing this in terms of code reuse. Is there any more generic way I can display info about multiple custom objects on a single page?

Is it possible to set the RecordType field for an object by name via the data loader?

 

At present, I just obtain a copy of the RecordType IDs and use a VLOOKUP in Excel to map them prior to import which might end up being a problem for end users.

 

I was thinking of having an additional custom field that gets updated with the record type name via a trigger prior to inset and update. That's another SOQL query though, and while I'm not close to hitting governer limits now, that may change in the future as we add functionality.

 

If the answer to my question below is negative, which is my suggested solutions should I go for?