• Damien_2
  • NEWBIE
  • 25 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 15
    Replies

Hi all,

 

I was wondering if it's possible to do a "double.valueof(string)" and avoid the "Invalid Double" error if my string is something like:

 

"3 is the magic number"

 

My string will always begin with a number (just trust me, it will), but it could be of any length, so I can't use "substring". Any ideas?

 

Thanks,

Lee

I keep getting the following error code when making my call:

System.HttpResponse[Status=Length Required, StatusCode=411]

I have the Http Request working using the google chrome plugin called 'Dev HTTP Client', but it does not work using the same values in Salesforce. My code that executes the callout looks like:

private void sendNotification()
{
	HttpRequest req = new HttpRequest();
	HttpResponse res = new HttpResponse();
	Http http = new Http();
	
	String tempPt = 'some valid url';
	
	req.setEndpoint(tempPt);// + '?client_token='+ token + '&client_secret=' + secret);
	req.setHeader('Cache-Control', 'no-cache');
	req.setHeader('Content-Length', '512');//I've tried various values here

	req.setMethod('GET');

	req.setCompressed(true);
	try
	{
		res = http.send(req);
		System.debug('res = ' + res);
		ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, '' + res));
	} catch(System.CalloutException e)
	{
		System.debug('Callout error: '+ e);
		System.debug(res.toString());
		ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, '' + e));
	}
}

 

 

I'm working with an external System that has a 'Shared Secret' and provides a URL for the different callouts.  I'm not quite sure where to use the secret that I have created with the external system.  I'm not sure what else to add to what I have below.  Could anyone give me a little guidance or help please?

 

public class CaseSearchController
{
	public List<Case> calloutCases{get;set;}
	private String endPoint = 'my endpoint is here';
	private String secret = 'my secret is here';
	
	public CaseSearchController()
	{
		init();
	}
	
	private void init()
	{
		getCases();
	}
	
	private void sendCases()
	{
		HttpRequest req = new HttpRequest();
		HttpResponse res = new HttpResponse();
		Http http = new Http();

		req.setEndpoint(endPoint);
		req.setMethod('GET');
		req.setCompressed(true);

		try
		{
			res = http.send(req);
			System.debug('res = ' + res);
		} catch(System.CalloutException e)
		{
			System.debug('Callout error: '+ e);
			System.debug(res.toString());
		}
	}
}

 

//I just executed the code like this in my dev env that has 5k accounts and it took about 30 seconds.

For (Account a: Database.query(query))

 

//I just executed the code like this in my dev env that has 5k accounts and it was instant.

List<Account> accs = Database.query(query);

For (Account a: accs)

 

Does anyone know if salesforce realizes the inefficiencies here and if this will be fixed?

All of the helpful links... if you are having issues logging in... don't actually take you anywhere helpful to contact anyone.  Does anyone know what I need to do if I'm having issues logging in?

Hi all,

 

I was wondering if it's possible to do a "double.valueof(string)" and avoid the "Invalid Double" error if my string is something like:

 

"3 is the magic number"

 

My string will always begin with a number (just trust me, it will), but it could be of any length, so I can't use "substring". Any ideas?

 

Thanks,

Lee

I keep getting the following error code when making my call:

System.HttpResponse[Status=Length Required, StatusCode=411]

I have the Http Request working using the google chrome plugin called 'Dev HTTP Client', but it does not work using the same values in Salesforce. My code that executes the callout looks like:

private void sendNotification()
{
	HttpRequest req = new HttpRequest();
	HttpResponse res = new HttpResponse();
	Http http = new Http();
	
	String tempPt = 'some valid url';
	
	req.setEndpoint(tempPt);// + '?client_token='+ token + '&client_secret=' + secret);
	req.setHeader('Cache-Control', 'no-cache');
	req.setHeader('Content-Length', '512');//I've tried various values here

	req.setMethod('GET');

	req.setCompressed(true);
	try
	{
		res = http.send(req);
		System.debug('res = ' + res);
		ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, '' + res));
	} catch(System.CalloutException e)
	{
		System.debug('Callout error: '+ e);
		System.debug(res.toString());
		ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, '' + e));
	}
}

 

 

I am trying to write a trigger to update the case owner to "current user" when the case is closed but I only want to do this for a particular role.  I believe the trigger below will update to current user on case close but I do not know how to limit it to a particular role.  Any help will be greatly appreciated.

 

trigger CaseUpdate on Case (before update) {
    if (Trigger.new.size() == 1) {  
        // if a Case has been updated to Closed
        if (Trigger.new[0].Status == 'Closed') {  
            // Change Trigger.old[0].OwnerId to Current User ID
            Trigger.new[0].OwnerId = UserInfo.getUserId();
        }
    }
}

//I just executed the code like this in my dev env that has 5k accounts and it took about 30 seconds.

For (Account a: Database.query(query))

 

//I just executed the code like this in my dev env that has 5k accounts and it was instant.

List<Account> accs = Database.query(query);

For (Account a: accs)

 

Does anyone know if salesforce realizes the inefficiencies here and if this will be fixed?

All of the helpful links... if you are having issues logging in... don't actually take you anywhere helpful to contact anyone.  Does anyone know what I need to do if I'm having issues logging in?

I am trying to make a custom page in my Customer Portal that shows ALL the cases of an account instead of just that specific user's. 

 

The SQL statement I am using in my VisualForce page to do this is:

 

    SELECT CaseNumber, AccountId, Subject FROM Case WHERE AccounttId = {!$User.AccountId}

 

However, I get this error:

 

    Error: Field AccountId does not exist. Check spelling 

 

How would I create this custom page that shows all cases?

  • September 25, 2012
  • Like
  • 0

Hi ,

 

Could someone please point out the difference between 'save to database' and 'Commit to database'? This will be really helpful.

 

Thanks

Sam

Hi All,

 

I have one component(testcomponent) which is having a check box like sample below

 

<apex:component controller="test" id="check">

<apex:inputCheckbox value={}" id="bopt" />

</apex:component>

 

And one Vf Page which has the component in it  and also one save button like

<apex:page controller="test1" id="pid">

<apex:commandButton value=" Save" title="Save Entire Page" />

<c:testcomponent>

</apex:page>

 

 I need to disable the check box if it already been checked when page is loaded.

this i have done using the java script function

below function is working fine , it disabling the check box when the  page is loading.

 

function disableCheckBox(){    

 if({!accountDetail.OptOutSettings.brandOptOut==true}  ){
    document.getElementById('{!$Component.check.bopt}').disabled=true;
    }
    else{
    document.getElementById('{!$Component.check.bopt}').disabled=false;
    }
}

 Function was called in document ready state 

$(document).ready(function() {

disableCheckBox();

}

 

but when i click save button on VF page checkbox is enabling again and also lost the previous data.

Can anyone suggest how to disable the check box which is  in component when I click the save button on vf page.

 

Thank you

 

  • January 27, 2012
  • Like
  • 0