• anchovies
  • NEWBIE
  • 25 Points
  • Member since 2013

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 12
    Replies

 Hi All,

 

      I have button in vf page, whenever i click that button i want to display the detail page of that record.

 

      Can any one help me how to solve.

 

Thanks

 

Hi all,



I'm trying to send an attachment body tio sharepoint server but keep getting 401 error (not autorized). The same endpoint and credentials work fine from C# though.



Can anyone help me out here?

 

string endpoint = 'http://mysharepoint_server_url/foldername/';
string username = 'domain/username';
string password = 'password';

Http http = new Http();
HttpRequest req = new HttpRequest();

Blob headerValue = Blob.valueOf(username + ':' + password);
String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
eq.setHeader('Authorization', authorizationHeader);

Attachment a = [SELECT Id, Name, Body, BodyLength, ContentType from Attachment WHERE Id = 'myattachmentid' LIMIT 1];
req.setTimeout(120000);
req.setBodyAsBlob(a.Body);
req.setMethod('PUT');
string newfilepath = string.format('{0}{1}{2}.docx', new string[] {endpoint, 'SFAttachment_', a.Id});
req.setEndpoint(newfilepath);
Blob reqbody = a.Body;
req.setBodyAsBlob(reqbody);
req.setHeader('Content-Length', a.BodyLength.format());
req.setHeader('Content-Type', a.ContentType);

HTTPResponse res = http.send(req);

 

Thanks in advance

Hi all,

I'm trying to create a custom SF webservice and the call it from my .NET app.

So I'm adding my service's WSDL in VS 2012. It does work for a tiny test webservice that returns a string but it doesn't work when I want to return an opportunity.

Can I return sObjects at all?

In case I can, then here are some details:

By not working I mean that I can't reference my web reference in code and when I try to update web reference I'm getting the following error:

VS error

Is there a workaround for this?

 

My tiny test service code is the following (it does work when called from Apex):

global class OpportunitySearch {
    webService static Opportunity[] getOpportunities()
    {
        Opportunity[] searchResults = Database.query('SELECT Name, Id FROM Opportunity  LIMIT 10');
        return searchResults;
    }
}

It behaves the same way when I'm trying to return a single Opportunity or an Account.

 

Thanks in advance

Hi all,

I used to work with enterprise and partner SF API a couple of years ago and it used to be so easy. But now I can't make it work after login and the documentation doesn't help at all.

The error I'm getting is the following:
UNKNOWN_EXCEPTION: Destination URL not reset. The URL returned from login must be set in the SforceService

I do realize I'm getting it back in my loginresult but the documentation doesn't tell me how to set it. Examples show completely different reference! For instance, here http://www.salesforce.com/us/developer/docs/api/.

Even the login call is different, the docs example say login(username, password) but my service reference wants three arguments, it also needs LoginScopeHeader (however passing a null instead of it still work).

Can please someone point me to the relevant source of information here? Or do I have to dig into wsdl?..

Thanks in advance

Hi all,

 

What's the best approach to create a self-dependent picklist?

 

What I'm trying to do is to restrict values available for selection based on the current picklist value. E.g. if an opportunity stage is 'Negotiation' it can't go back to 'Prospecting'.

 

Thanks in advance

Hi all,

What records are created in SF db during mass email? I thought that would be Tasks (from the activity reports) but my trigger on task doesn't seem to be called.

What I am trying to achieve:

During mass email, I need to suppress leads and contacts that have already been emailed in the last 60 days. I've put a trigger on task that would fill lead/contact custom field with today's date. This field is then used in mass email views filters.

Please advise how to track this information.

Thanks in advance!

Hi all,

I'm currently working on a trigger for preventing duplicate Leads from being inserted during the mass data upload. The trigger should treat two leads equal if their Company and Email fields are equal. Since the trigger would fire during the mass data upload (custom), I had to minimize the number of executed SOQL queries in order to cope with SF limits.

Here's how the code looks like atm:

trigger MyTrigger on Lead (before insert) {

Map<String, Lead> leadMap = new Map<String, Lead>();

List<String> fieldNames = new List {'Email', 'Company'}; // it will actually be obtained from somewhere else, but I'm hardcoding it atm

String leadQueryString = '';
String leadDupeError = 'A Lead with the same {0} already exists: {1}';
String fieldSet = '';
Integer i = 0;

List<Set<String>> leadValues = new List<Set<String>>(); // referencing a set by its index in the list doesn't work in dynamic query

for (String fieldName : fieldNames)
{
	Set<String> thisFieldValues = new Set<String>();
	
	for (Lead lead : System.Trigger.new)
	{
		if(String.isNotBlank((String)lead.get(fieldName))) thisFieldValues.add((String)lead.get(fieldName));
	}
	// keeping a corresponding set of values for this field
	leadValues.add(thisFieldValues);
	
	// constructing my query filters
	leadQueryString += (leadQueryString == '' ? '' : ' AND ') + fieldName + ' IN :leadValues[' + i + ']'; // this index doesn't work	
	fieldSet += (fieldSet == '' ? '' : ', ') + fieldName;
	
	i++;
}

List<Lead> possibleDupes = Database.query('SELECT Id, ' + fieldSet + ' FROM Lead WHERE ' + leadQueryString);

List<Lead> dupes = new List<Lead>();

for (Lead lead : System.Trigger.new)
{
	for (Lead pd : possibleDupes)
	{
		boolean match = true;
		
		for(String fieldName : fieldNames)
		{
			if (((String)lead.get(fieldName)) != (String)pd.get(fieldName)) {
				match = false;
				break;
			}
		}
		if (match) {
			lead.addError(String.format (leadDupeError, new List<String> { fieldSet, pd.Id})); // this will prevent the insert
			dupes.add(lead);
			break;
		}
	}
}

}

 Actually, referencing leadValues[i] in query doesn't work :( It gives me the following error:  System.QueryException: unexpected token: '['
To get it work, I had to remove the [] clauses from the query and add two additional lists: 

leadValues0 = leadValues[0]
leadValues1 = leadValues[1]

This way it does work, but it's not dynamic (I want the number of filter fields be more flexible).

So, the question is: is there a way to bypass this error without having to keep the exact number of field values sets?

I would also appreciate any other suggestions on improving my trigger :)

Hi all! I'm working on a wizard that consists of 4 pages sharing the same controller. Unfortunately, development mode footer disapears on page 3 and I can't check the view state. Are there any other ways to get it? Or does anyone know why it disappears?

Hi all,



I'm trying to send an attachment body tio sharepoint server but keep getting 401 error (not autorized). The same endpoint and credentials work fine from C# though.



Can anyone help me out here?

 

string endpoint = 'http://mysharepoint_server_url/foldername/';
string username = 'domain/username';
string password = 'password';

Http http = new Http();
HttpRequest req = new HttpRequest();

Blob headerValue = Blob.valueOf(username + ':' + password);
String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
eq.setHeader('Authorization', authorizationHeader);

Attachment a = [SELECT Id, Name, Body, BodyLength, ContentType from Attachment WHERE Id = 'myattachmentid' LIMIT 1];
req.setTimeout(120000);
req.setBodyAsBlob(a.Body);
req.setMethod('PUT');
string newfilepath = string.format('{0}{1}{2}.docx', new string[] {endpoint, 'SFAttachment_', a.Id});
req.setEndpoint(newfilepath);
Blob reqbody = a.Body;
req.setBodyAsBlob(reqbody);
req.setHeader('Content-Length', a.BodyLength.format());
req.setHeader('Content-Type', a.ContentType);

HTTPResponse res = http.send(req);

 

Thanks in advance

Hi all,

I'm trying to create a custom SF webservice and the call it from my .NET app.

So I'm adding my service's WSDL in VS 2012. It does work for a tiny test webservice that returns a string but it doesn't work when I want to return an opportunity.

Can I return sObjects at all?

In case I can, then here are some details:

By not working I mean that I can't reference my web reference in code and when I try to update web reference I'm getting the following error:

VS error

Is there a workaround for this?

 

My tiny test service code is the following (it does work when called from Apex):

global class OpportunitySearch {
    webService static Opportunity[] getOpportunities()
    {
        Opportunity[] searchResults = Database.query('SELECT Name, Id FROM Opportunity  LIMIT 10');
        return searchResults;
    }
}

It behaves the same way when I'm trying to return a single Opportunity or an Account.

 

Thanks in advance

Hi all,

I used to work with enterprise and partner SF API a couple of years ago and it used to be so easy. But now I can't make it work after login and the documentation doesn't help at all.

The error I'm getting is the following:
UNKNOWN_EXCEPTION: Destination URL not reset. The URL returned from login must be set in the SforceService

I do realize I'm getting it back in my loginresult but the documentation doesn't tell me how to set it. Examples show completely different reference! For instance, here http://www.salesforce.com/us/developer/docs/api/.

Even the login call is different, the docs example say login(username, password) but my service reference wants three arguments, it also needs LoginScopeHeader (however passing a null instead of it still work).

Can please someone point me to the relevant source of information here? Or do I have to dig into wsdl?..

Thanks in advance

Hi all,

 

What's the best approach to create a self-dependent picklist?

 

What I'm trying to do is to restrict values available for selection based on the current picklist value. E.g. if an opportunity stage is 'Negotiation' it can't go back to 'Prospecting'.

 

Thanks in advance

Hi all,

What records are created in SF db during mass email? I thought that would be Tasks (from the activity reports) but my trigger on task doesn't seem to be called.

What I am trying to achieve:

During mass email, I need to suppress leads and contacts that have already been emailed in the last 60 days. I've put a trigger on task that would fill lead/contact custom field with today's date. This field is then used in mass email views filters.

Please advise how to track this information.

Thanks in advance!

Hi all,

I'm currently working on a trigger for preventing duplicate Leads from being inserted during the mass data upload. The trigger should treat two leads equal if their Company and Email fields are equal. Since the trigger would fire during the mass data upload (custom), I had to minimize the number of executed SOQL queries in order to cope with SF limits.

Here's how the code looks like atm:

trigger MyTrigger on Lead (before insert) {

Map<String, Lead> leadMap = new Map<String, Lead>();

List<String> fieldNames = new List {'Email', 'Company'}; // it will actually be obtained from somewhere else, but I'm hardcoding it atm

String leadQueryString = '';
String leadDupeError = 'A Lead with the same {0} already exists: {1}';
String fieldSet = '';
Integer i = 0;

List<Set<String>> leadValues = new List<Set<String>>(); // referencing a set by its index in the list doesn't work in dynamic query

for (String fieldName : fieldNames)
{
	Set<String> thisFieldValues = new Set<String>();
	
	for (Lead lead : System.Trigger.new)
	{
		if(String.isNotBlank((String)lead.get(fieldName))) thisFieldValues.add((String)lead.get(fieldName));
	}
	// keeping a corresponding set of values for this field
	leadValues.add(thisFieldValues);
	
	// constructing my query filters
	leadQueryString += (leadQueryString == '' ? '' : ' AND ') + fieldName + ' IN :leadValues[' + i + ']'; // this index doesn't work	
	fieldSet += (fieldSet == '' ? '' : ', ') + fieldName;
	
	i++;
}

List<Lead> possibleDupes = Database.query('SELECT Id, ' + fieldSet + ' FROM Lead WHERE ' + leadQueryString);

List<Lead> dupes = new List<Lead>();

for (Lead lead : System.Trigger.new)
{
	for (Lead pd : possibleDupes)
	{
		boolean match = true;
		
		for(String fieldName : fieldNames)
		{
			if (((String)lead.get(fieldName)) != (String)pd.get(fieldName)) {
				match = false;
				break;
			}
		}
		if (match) {
			lead.addError(String.format (leadDupeError, new List<String> { fieldSet, pd.Id})); // this will prevent the insert
			dupes.add(lead);
			break;
		}
	}
}

}

 Actually, referencing leadValues[i] in query doesn't work :( It gives me the following error:  System.QueryException: unexpected token: '['
To get it work, I had to remove the [] clauses from the query and add two additional lists: 

leadValues0 = leadValues[0]
leadValues1 = leadValues[1]

This way it does work, but it's not dynamic (I want the number of filter fields be more flexible).

So, the question is: is there a way to bypass this error without having to keep the exact number of field values sets?

I would also appreciate any other suggestions on improving my trigger :)

 Hi All,

 

      I have button in vf page, whenever i click that button i want to display the detail page of that record.

 

      Can any one help me how to solve.

 

Thanks

 

Hi all! I'm working on a wizard that consists of 4 pages sharing the same controller. Unfortunately, development mode footer disapears on page 3 and I can't check the view state. Are there any other ways to get it? Or does anyone know why it disappears?

how can we show more than 1000 records in visualforce page?

  • October 30, 2013
  • Like
  • 0