• ahab1372
  • NEWBIE
  • 463 Points
  • Member since 2007

  • Chatter
    Feed
  • 17
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 196
    Replies

Hello.  On p. 420 of the 2008 Force.com Developers Guide (distributed at Dreamforce 2008), it says that "Message.sendMail method takes an array of messages to send, so you can send multiple messages in one single call."

 

Does this mean I can send an array of different email messages, each to a single recipient, in one call?  What is the syntax for constructing the array?  The documentation is not clear.

 

Here are the specifics of my situation: I need to send an email containing a personalized URL to several people, and I can't use merge fields/templates because the people's data are stored in a custom object, not in the Contact object.

 

Thanks

David

I have a requirement to create a trigger that runs on the CaseComment object and does a string replacement on the contents of the comment body.

 

I need this trigger to modify CaseComments belonging to Cases of only 1 record type.

 

In order to do this, I have to check the RecordTypeId field of each CaseComment's parent Case. I'm having trouble figuring out how to do this without placing a SOQL query inside of the trigger.new for loop. I've tried two different methods:

 

   This method uses a single query to pull ALL the cases from the DB that match the RecordTypeID, then checks to see if each CaseComment matches one of those cases.

 

 

ID myCaseId = '0120000000095y7';
	//Fetch all needed Cases from the database
	List<Case> cases = [SELECT Id FROM Case WHERE RecordTypeId = :myCaseId];
	
	//For all new CaseComments,
	for(CaseComment c : trigger.new) {
		//Iterate through the cases
		for(Case c : cases) {
			//if this CaseComment matches a selected case 
			if(e.ParentID == c.Id) {
							
				//make the replacement........

 This doesn't work because I have 500+ cases and the governer limit stops me.

 

 

 

The second thing I tried to do was query the RecordTypeId of the CaseComment's parent Case directly via the relationship between them. (CaseComment.Parent.RecordTypeId)

 

        //PTI Support Case RecordTypeID
	ID myCaseId = '0120000000095y7';
	
	for(CaseComment comm : trigger.new) {

		if(comm.Parent.RecordTypeId == myCaseId) {
			//make the replacement...
		

 

 

This doesn't work because the relationship returns "null" for the RecordTypeId.

 

The trigger is running before update.

 

Does anyone have a solution to this?

Hello

I am using SF Soap API

I would like to add carriage return line feed in a long text area

I have tried  <urn1:Log__c>value1\nvalue2</urn1:Log__c> or <urn1:Log__c>value1\r\nvalue2</urn1:Log__c>

And when I go to SF there is no carriage return but \n or \n\r instead of carriage return

What is the solution ?

Thanks for your help

regards

I want to expose some content on a sites VF page. There are some complex business rules to determine which users get access to which content, so I can't use any standard functionality.

 

Here's the VF page

 

<apex:page action="{!showContent}" contentType="application/octet-stream" controller="MyDocsController" showHeader="false" sidebar="false">
<apex:outputText value="{!contentBody}" escape="false"/>
</apex:page>

 

<apex:page action="{!showContent}" contentType="application/octet-stream" controller="MyDocsController" showHeader="false" sidebar="false">

<apex:outputText value="{!contentBody}" escape="false"/>

</apex:page>

 

Here's the relevant part of the controller:

 

 

public pageReference showContent() {

...

ContentVersion theDoc = [select id, VersionData from contentVersion where id = :docId];

contentBody = theDoc.VersionData;

...

 

 

 

When I invoke this page from  .../apex/ShowContent?docId=068... my browser downloads a file called "ShowContent".

The body of this file is the text core.filemanager.FileBlobValue@1e74039

 

I have 2 questions:

1) Is there any way for me to change the file to something sensible, such as the filename in the contentVersion object

2) How can I get at the actual BLOB as a stream of bytes instead of a pointer reference.

 

 

Thanks,

David.

We want to create a custom button to add PDF Attachement to the object record. We havea visuaforce page which generates a PDF document. We are creating another button on the details page to add this PDf document as a attachment. We want this attachment to be added automatically when user clicks on this button. We do not want to include another intermediate page to get user confirmation.

 

Inititially our page was working when we created a page by just calling the attach method from action on <apex:page> it self.

 

In order to avoid Cross-Site Request Forgery (CSRF), we are trying out the action poler or java script to auto execute the action when detail page button is clicked.

 

It is generating folloiwng error when we try to open the attachment in notes & attachment section

 

File does not begin with '%PDF-'

 

Following is the apex controller code

 

public with sharing class WorkOrderPDFExtensionCon {
	ApexPages.StandardController controller;
	Id id;
	public WorkOrderPDFExtensionCon (ApexPages.StandardController c) {
		 id = ApexPages.currentPage().getParameters().get('id');
		 controller = c;
	}
	public PageReference attachWorkOrder() {
		   WorkOrder__c WO = [Select id, name from WorkOrder__c where id = :id];
		   PageReference pdfPage = Page.gii__WorkOrderPDFDocument;
			PageReference WOPage = new PageReference('/' + id) ;
			WOPage.setRedirect(true);

		   //  set the Work Order id on the page definition 
			pdfPage.getParameters().put('id',id);

			// generate the pdf blob 
			Blob pdfBlob = pdfPage.getContent();
			
			// create the attachment against the Work Order
			Attachment a = new Attachment(parentId = id, name=WO.name + '.pdf', body = pdfBlob);
			// insert the attachment 
			insert a;
			return WOPage;
	  }
}

 

 

Follwoing is the Vf page for with action poler. It is generating error File does not begin with '%PDF-' when attachment is viewed.

 

 

<apex:page standardController="WorkOrder__c"  extensions="WorkOrderPDFExtensionCon" setup="false" sidebar="false">
     <apex:sectionHeader Subtitle="{!WorkOrder__c.name}" title="Attach Work Order"/>                
      <apex:form id="mainform">   
      <apex:actionFunction name="executeAction" action="{!attachWorkOrder}"/>
      <script>window.setTimeout(executeAction,500)</script> 
    </apex:form>
</apex:page>

Gives Error - File does not begin with '%PDF-'

<apex:page standardController="WorkOrder__c"  extensions="WorkOrderPDFExtensionCon" setup="false" sidebar="false">
     <apex:sectionHeader Subtitle="{!WorkOrder__c.name}" title="Attach Work Order"/>                
      <apex:form id="mainform">   
      <apex:actionPoller id="executeAction" action="{!attachWorkOrder}" interval="5"/>
     
    </apex:form>
</apex:page>

Gives Error - File does not begin with '%PDF-'

 

 

And Following code works perfectly when attachment is created by clicking on a button

 

<apex:page standardController="WorkOrder__c"  extensions="WorkOrderPDFExtensionCon" setup="false" sidebar="false">
     <apex:sectionHeader Subtitle="{!WorkOrder__c.name}" title="Attach Work Order"/>                
    <apex:form id="mainform">   
        <apex:pageBlock >
		    Are You Sure :
           <apex:pageBlockSection collapsible="false" title="Attach" columns="2">
                    <br/> Are You Sure ?
           </apex:pageBlockSection>
           <apex:pageBlockButtons location="bottom">  
               <apex:commandButton id="confirm" style="btn" value="{!$Label.Attach}"  action="{!attachWorkOrder}" />&nbsp;&nbsp;
               <apex:commandButton id="cancel" style="btn" value="{!$Label.Cancel}" action="{!cancel}" />
           </apex:pageBlockButtons> 
        </apex:pageBlock>     
    </apex:form>
</apex:page>

 

 

I want to know how we can avoid a intermediate confirmation page witout getting error File does not begin with '%PDF-'. and also what actually this error is and why we are getting this error.

 

Any ideas,, any help is much appreciated.

 

thanks

 

 

 

 

 

 

 

 

How do you install SalesForce releases once they become available (Ex:  Spring '10 Release)?  Also, is there a way to check your current production version?  Thanks! 

I am creating a questionnaire in which a record is created after the completion of page one.  Upon clicking "Next" the record is checked for validation errors, if none it saves and if there are then the page displays those erros.  On multiple page questionnaires, I'm not sure how to grab the ID of the record created on page one so it can be updated with the responses from questions located on page 2.

 

Here is the code I am using:

public PageReference doSave() {

    try {

        this.ctr.Save();

    }  catch(DmlException ex){

        //this catches the errors and ensures they register on the page

        ApexPages.addMessages(ex);

    }

 

 

    //if there's an error message, perform a refresh

    // if not, redirect to google.com

    if (ApexPages.hasMessages()) {

        return null;

    } else {

        return new PageReference('url of page 2');   

    }

}

 

 

Any ideas?

Hello,

 

I'm fairly new to SalesForce and am working on some test code to get familiar with the platform. At present, I have created two custom classes (Payment__c and Project__c) and modified an existing class (Contact) successfully. Now I am attempting to create a trigger on Payment__c such that when it is modified (instert, update, delete) it will modify fields on the Project__c and Contact objects.

 

Note that Payment__c contains a Currency field named amount, a reference to a Project__c object and a reference to a Contact object. The trigger is supposed to update fields in the Project__c and Contact objects when a payment is inserted, updated, or deleted.

 

My trigger is very simple:

 

trigger ModifyPaymentToProject on Payment__c (after insert) {
	PaymentAction.modifyPayment(trigger.new); 
}

 

 The class PaymentAction:

 

public with sharing class PaymentAction {
	public static void modifyPayment(List<Payment__c> payments) {
		for (Payment__c payment : payments) {
			// Do something here
		}
	}
}

 And I have a test for this PaymentTest:

 

@isTest
private with sharing class PaymentTest {
	
	static testMethod public void paymentTest() {
		Project__c project = new Project__c();
		insert project;
		Contact contact = new Contact();
		contact.FirstName = 'me';
		contact.LastName = 'myself';
		contact.Email = 'me@myself.com'; 
		insert contact;
		Decimal testAmt = 50.00;
        		Payment__c payment = new Payment__c(Project__c = project.Id, 				Contact__c = contact.Id, Amount__c = testAmt);
        		insert payment;
        		System.assertEquals(payment.amount__c, testAmt);
    }
}

General Info: I am currently using version 18 of the SalesForce app and working with Eclipse with the SalesForce plugin.

 

My test class (PaymentTest) is giving me a warning that it is saved locally, not to the server and my trigger is giving the warning 'Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required'

 

Running the tests from Eclipse or the browser produce the same results: 0% coverage for my Payment and PaymentAction classes. Does anyone have some suggestions as to what I should be doing here?

 

 

Regards,

 

Tim

I recently upgraded Eclipse to support Spring 10 / API v18.

 

Now, when I create a new class from Eclipse, it will default the API to v18.

 

What do people generally do about all of the existing v16 classes, triggers, pages they have created?  Would you suggest doing a 1 time upgrade by going to each component and upgrading to the new API.  Or do them one at a time as they get changed over time with on-going development/fixes?

 

In order to upgrade to, is it best to use the salesforce web UI or do it via the metadata XML in eclipse?

  • April 30, 2010
  • Like
  • 0

Hi all:

 

The organization I am working for is a reseller of products. For some opportunities, they need to send an inquiry to the manufacturer to get a custom quote. They have defined a custom field in the Opportunity called Inquiry_Sent_To__c that references a specific Contact.

 

I'm working on developing a VisualForce page to automatically send an email to that manufacturer from the Oppt'y. I'm using the Oppt'y Standard Controller. I've tried {!Inquiry_Sent_To__r.Email} and I get the error  "Unknown property 'OpportunityStandardController.Inquiry_Sent_to__r}".  When I try {!Opportunity.Inquiry_Sent_To__c.Email} I get the error "Unknown property 'String.Email".

 

What am I missing here? Thanks.

I have a map of two strings.  I want to put the map in a simple loop and print out the key and value pairs.  Is this possible?

Hi:

   I am getting duplicate ID's in my trigger when really there are no dups in my list???

Where am I going wrong:

 

trigger updateSubjectArea on Subject_Area_RQ__c (after insert,after update) {
 List<Subject_Area__c> htoUpdte = new List<Subject_Area__c>();
Subject_Area__c sa;
Set <ID> setOrderId = new set<ID>();
for (Subject_Area_RQ__c orderDetail :trigger.new) 
    {
    setOrderId.add(orderDetail.Subject_Area__c);
    }
 
List<Subject_Area__c> accounts = [SELECT Id FROM Subject_Area__c where Id IN :setOrderId];

for(Subject_Area_RQ__c sar : trigger.new){ 
for(Subject_Area__c a: accounts){
         a.SARQ__c = sar.On_Track_Subject_Area__c;
System.Debug('a.SARQ__c - ' +sar.On_Track_Subject_Area__c);
htoUpdte.add(a);
}
update htoUpdte; 
}
}

 

 

I have a pdf document generated from fields on an opportunity. I need to then attach it to the opportunity it came from. So far I have code that looks like this:

 

 

Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('https://c.cs2.visual.force.com/apex/PDF?Id=' + o.Id);
req.setMethod('GET');
HttpResponse res = h.send(req);
Attachment a = new Attachment(Name = 'Attachment Name', ParentId = o.Id, Body = Blob.valueOf(res.getBody()));
insert a;

 

 

When I run it, it clreates an attachment and attaches to the right opportunity, but the attachment itself is not the pdf but rather some small text file that reads:

 

The URL has moved <a href="https://cs2.salesforce.com/visualforce/session?url=https%3A%2F%2Fc.cs2.visual.force.com%2Fapex%2FPDF%3FId%o.Id">here</a>

 

 

Can anyone help me figure out what's going on? Again, all I need to do is take a pdf generated by a vf page and attach it to the coresponding opportunity. Thanks!

  • April 27, 2010
  • Like
  • 0

I created a custom object, "Sites", and added it to the cases fields. It is also linked to accounts such that "Sites" shows up as a seperate area in each Account object. (I intend to use it to identify all the physical locations of an account. Each account has multiple sites.)

 

The problem is that "Site" isn't showing up in the layout page for "log a case" in the self service portal. Answers?

 

Since I'm on the topic, here is another question: When a customer opens a case via the self-service portal, I'd like them to select two different criteria: site and type of problem. From that criteria I like to set another field in the case, "billing code". This is all common, basic stuff. Is this doable using the salesforce out of the box or do I have install or write an app or use my own web server to do all the heavy lifting? Basically, I am trying to get it to performing a set operation based on the following relational db query:

 

get billingCode WHERE billingCode.caseReason = "mac" AND billingCode.site = "site" AND billingCode.account ="logged in account"

 

How do I do this in the self-service portal, or is there a better way?

  • April 25, 2010
  • Like
  • 0

Hi my skills are pretty basic however I think my task is pretty basic with this trigger.  I've looked on the boards and found people answering this question but I am missing something and was hoping someone could let me know what I'm missing.  Because you can't update a lookup field on a parent record master-detail through a workflow rule I am writing a trigger to do it. 

Scenario:

I have three objects  IC_Asset__c  is the parent of a master-detail relationship with Checkin_Checkout_History__c .  On IC_Asset object there is a lookup field called In_possession_of__c to a Staff__c object.  On Checkin_Checkout_History__c there is a lookup field called Asset_History__c to the same Staff__c object.

 

I want to write the contents of Asset_History__c field to In_possesion_of__c field on IC_Asset__c after an edit on Checkin_Checkout_History__c.

---------------------------------------------------------------------------------------------------------------------------

trigger SetInPossessionOf on Checkin_Checkout_History__c (before update) {

//create a set of all unique IC_Asset ids

    Set<Id> assetIds = new Set<Id>();
         for (Checkin_Checkout_History__c chk : Trigger.new)
    // Add ids of lookup on Checkin_Checkout_History__c to assetIds
            assetIds.add(chk.Asset_Lookup__c);
        
// create a map so that IC_Assets are locatable by Id
    Map<Id, IC_Asset__c> icaMap = new Map<Id, IC_Asset__c>(
    [SELECT Id,In_possession_of__c,text_field_asset__c FROM IC_Asset__c WHERE Id IN :assetIds]);
    
    for (Checkin_Checkout_History__c chk : Trigger.new){
        // get the IC_Asset__c from the map by its id
         icaMap.get(chk.Asset_Lookup__c).In_possession_of__c = chk.Staff__c;

-------------------------------------------------------------------------------------------------------------------------------------

Nothing happens. 

 

I can copy field to field on the record

chk.text_field__c = chk.text_field_chkout__c;

I can even copy from the parent lookup to a text field

chk.text_field_chkout__c= icaMap.get(chk.Asset_Lookup__c).In_possession_of__c;

But when I try to copy up to the parent I get nothing whether copying to a lookup or text field

icaMap.get(chk.Asset_Lookup__c).text_field_asset__c = chk.text_field_chkout__c;

 

Please help, thanks

 

Hi, I'm trying to parse a large string (~6570 characters) in apex through splitting. Specifically, I have the whole string separated about evenly into 8 sections by pipe ('|') characters (so very roughly about 821 characters per list element).

These lists are split even further, but I have commented out that code, and I still receive the error

System.ListException: Split results in a list that exceeds limits

upon splitting the first, biggest string into just 8 segments.

I'm not sure if the big picture is needed, so I'll try to describe it as concisely as I can. In my visualforce page, the giant string is constructed in javascript, then sent through an actionFunction as a param to the apex code on the server side. The receiving method then sends the giant string to an asynchronous method that parses the string and updates approximately 150 records. It is in this function where the error occurs.

I do not understand what limit I am breaking, so I was hoping someone could please clarify. Has anyone else possibly run into the same or similar problem? Moreover, is there another method I can use to parse the string that would circumvent the issue? I'm still new to salesforce and apex/visualforce development, so I'm still learning these limitations and their corresponding workarounds.

Thank you.
  • August 18, 2009
  • Like
  • 0

I have a few picklist fields for which I've chosen a default value but when creating a new record of that type the default value is not selected, the None is.

The field is visible and required. The picklist option is available for the record type.

Any suggestions why my choice for a default is not being respected? Thanks.

  • May 26, 2009
  • Like
  • 0

I get an error message when I query for null values in double fields (currenciy fields for example).

 

 

Error Generated by request::
Opportunity where Type = 'Renewal' and Original_Renewal_Value__c =''

ERROR at Row:1:Column:56
value of filter criterion for field 'Original_Renewal_Value__c' must be of type double and should not be enclosed in quotes
ExceptionCode : 5077

 

 

This has been asked and solved for dates (example here: http://forums.sforce.com/t5/Other-Salesforce-Applications/Date-in-Query-gives-Error-Generated-by-request-ExceptionCode/m-p/160107), but for doubles it seems to be different. I digged through the code trying to get NULL into the query string, but with no luck.

 

Any ideas?

 

 

the installation guide for the Force.com IDE recommends NOT to use the cocoa versions of eclipse 3.5. Not that it matters for productivity if you use Carbon or Cocoa or 32 or 64bit, but I was curious and tried the Cocoa 64bit version and haven't had any problems yet.

 

Has anyone else tried and experienced any problems?

I have a piece of code that iterates over a list of strings and changes the strings. Strange thing is that in the end the list has not changed at all, although the modified string is clearly visible in the Debug log within the iteration.

 

I think I know a way around this with a second list, but I am still wondering why it does not work within the list. Don't we do it with sObjects all the time and it works (like iterating over Trigger.New)?

 

code (execute anonymous):

 

		String[] CCAddresses = new string[]{ 'first1.last1@gmail.com','first2.last2@gmail.com'};     
        System.debug('Address List:::::::::::: ' + CCAddresses);

        for (string address:CCAddresses)
        {
        	System.Debug('One Address::::::::::::: ' + address);
        	if(!address.endsWith('@company.com')) 
        	{
        		String newAddress = address + '.full';
        		address = newAddress;
				//address += '.full'; // this doesn't work either
        	}
        	System.Debug('One Address::::::::::::: ' + address);
        }
		
        System.debug('Address List::::::::::::' + CCAddresses);

 

 

Debug Log:

 

Anonymous execution was successful.

18.0 APEX_CODE,FINE;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;VALIDATION,INFO;WORKFLOW,INFO
12:20:13.162|EXECUTION_STARTED
12:20:13.162|CODE_UNIT_STARTED|[EXTERNAL]execute_anonymous_apex
12:20:13.165|METHOD_ENTRY|[3,9]|System.debug(String)
12:20:13.165|USER_DEBUG|[3,9]|DEBUG|Address List:::::::::::: (first1.last1@gmail.com, first2.last2@gmail.com)
12:20:13.165|METHOD_EXIT|[3,9]|debug(ANY)
12:20:13.165|METHOD_ENTRY|[7,10]|System.Debug(String)
12:20:13.165|USER_DEBUG|[7,10]|DEBUG|One Address::::::::::::: first1.last1@gmail.com
12:20:13.165|METHOD_EXIT|[7,10]|debug(ANY)
12:20:13.165|METHOD_ENTRY|[8,14]|String.endsWith(String)
12:20:13.165|METHOD_EXIT|[8,14]|endsWith(String)
12:20:13.165|METHOD_ENTRY|[14,10]|System.Debug(String)
12:20:13.165|USER_DEBUG|[14,10]|DEBUG|One Address::::::::::::: first1.last1@gmail.com.full
12:20:13.165|METHOD_EXIT|[14,10]|debug(ANY)
12:20:13.165|METHOD_ENTRY|[7,10]|System.Debug(String)
12:20:13.165|USER_DEBUG|[7,10]|DEBUG|One Address::::::::::::: first2.last2@gmail.com
12:20:13.165|METHOD_EXIT|[7,10]|debug(ANY)
12:20:13.165|METHOD_ENTRY|[8,14]|String.endsWith(String)
12:20:13.165|METHOD_EXIT|[8,14]|endsWith(String)
12:20:13.165|METHOD_ENTRY|[14,10]|System.Debug(String)
12:20:13.165|USER_DEBUG|[14,10]|DEBUG|One Address::::::::::::: first2.last2@gmail.com.full
12:20:13.165|METHOD_EXIT|[14,10]|debug(ANY)
12:20:13.165|METHOD_ENTRY|[17,9]|System.debug(String)
12:20:13.165|USER_DEBUG|[17,9]|DEBUG|Address List::::::::::::(first1.last1@gmail.com, first2.last2@gmail.com)
12:20:13.165|METHOD_EXIT|[17,9]|debug(ANY)
12:20:13.165|CUMULATIVE_LIMIT_USAGE
12:20:13.165|LIMIT_USAGE_FOR_NS|(default)|

 

 

 

 

Hi All,

I built a VF page with custom controller which calls another VF page that returns a PDF. The PDF is is extracted via getContent(), and attached to an email. It all works fine in the sandbox through the UI, but the test method fails, unfortunately without detailed log information.

 

I already found these two threads but none really points to an explanation why it fails in test methods while working fine in the UI:

http://community.salesforce.com/t5/Apex-Code-Development/error-quot-System-VisualforceException-quot-at-getContent/td-p/173307?view=by_date_ascending

 

http://community.salesforce.com/t5/Apex-Code-Development/RageReference-getContent-failing-on-Spring-10-release/td-p/168272

 

Here is the relevant code from the action method:

 

    public PageReference send(){

        for (string address:CCAddresses)
        {
        	if(!address.endsWith('@symmetricom.com')) address += '.full';
        }
        
        PageReference pdfPage = Page.quotePDF;
        pdfPage.getParameters().put('id',theQuote.ID);
        //pdfPage.setRedirect(true);
        System.Debug('pdfPage::::::::::::::::::::::::::::::::::::::: ' + pdfPage);
        transient Blob theBlob;
        theBlob = pdfPage.getContent();
        
        transient Attachment a = new Attachment (
            parentID = theQuote.ID,
            name = 'SymmQuote ' + theQuote.Name + '.pdf',
            body = theBlob);
        

 It fails at the line theBlob = pdfPage.getContent(); when called from the test method, otherwise it works fine. Error message is:

System.VisualforceException: List has no rows for assignment to SObject

The quotePDF page uses the same controller and I was wondering if that causes the issue. Maybe the test cannot handle another instance of the same controller? The PageReference for the pdfPage is created correctly

 

here is the test method:

 

		PageReference pageRef2 = Page.quoteSend;
		Test.setCurrentPage(pageRef2);
		ApexPages.currentPage().getParameters().put('id',quote1.Id);
		quoteLineEdit_v1 editController2 = new quoteLineEdit_v1();
		
		editController2.send();

 

 

 

 

 

 

 

 

 

Hi All,

If anyone is using the connector with API version 7.0 or higher and you encounter issues with queries including a date field, or if you want to increase the batch size to 200, try the following:

 

 Tweaking sforce excel connector
Do at your own risk.
These modifications are unsupported.


Modify query format for queries with date fields
• Only necessary if you use API 7.0 or higher and your query includes a date field (query returns an error)
• Open the Script editor from Excel (Alt + F11)
• In the Project sforce_connector, double-click “utils”
• In the upper right drop down menu, navigate to the function “sfQueryValueFormat”
• Change the line Case "datetime", "date": to Case "datetime":
• Add the following code block above the line Case "double", "currency", "percent":

 

 

Case "date":
If (InStr(LCase(vlu), "today")) Then
Dim today2 As Date: today2 = Date
Dim daychange2 As Variant, incr2%: incr2 = 0
If (InStr(LCase(vlu), "-")) Then
daychange2 = Split(vlu, "-")
incr2 = 0 - Int(daychange2(1))
End If
If (InStr(LCase(vlu), "+")) Then
daychange2 = Split(vlu, "+")
incr2 = Int(daychange2(1))
End If
vlu = DateAdd("d", incr2, today2)
End If ' 5.12 end

sfQueryValueFormat = Format$(vlu, "yyyy-mm-dd")

 

 

 

 


• Close the editor

 

Increase batch size of queries,inserts and updates
• Open the Script editor from Excel (Alt + F11)
• In the Project sforce_connector, double-click “s_force”
• Find the line Const maxBatchSize As Integer = 50 and change the value 50 to 200
• More than 200 will not work

I get an error message when I query for null values in double fields (currenciy fields for example).

 

 

Error Generated by request::
Opportunity where Type = 'Renewal' and Original_Renewal_Value__c =''

ERROR at Row:1:Column:56
value of filter criterion for field 'Original_Renewal_Value__c' must be of type double and should not be enclosed in quotes
ExceptionCode : 5077

 

 

This has been asked and solved for dates (example here: http://forums.sforce.com/t5/Other-Salesforce-Applications/Date-in-Query-gives-Error-Generated-by-request-ExceptionCode/m-p/160107), but for doubles it seems to be different. I digged through the code trying to get NULL into the query string, but with no luck.

 

Any ideas?

 

 

I have several partners that will be accessing opportuities so I thought record types would do this since the partners need access to more then one record type and its not yet determined which partner will have access to which opportunity record type. The accounts will have opportunities of several record types.

On each of  the partners profiles the I choose the record types, however this only prevented them from adding the other record types. I wanted to prevent them from editing/ deleting the other record type as well. And would be nice to prevent them from seeing the other record types on the account as well. How can I control access by record type?

 

Other info: Also the opportunities and accounts are both master related to a custom object that is similar to product/asset, which I'd also like to use record types on in the same way. Think of the partners as selling different products that are installed on the account. So they are given the opportunity to sell products. But 2 partners may need to be replaced by 1 partner in the future. However, the partner will not be creating the opportunities or products, so they will need to be quickly given permission later when its determined who sell what. Is the master relationship interfering with the permissions?

I have two Sharing Reasons on a custom object in a recruiting app.

 

If the candidate goes to "employee" status, i want to only share with the management group.

 

If the candidate goes to any other status, I will share with the employee group.

 

I have an after insert, update trigger on my candidate object. In the trigger I pull the existing shares like this:

 

 

	List <T7Candidate__Share> candidateShares = [SELECT Id, ParentId, UserOrGroupId,AccessLevel,RowCause FROM T7Candidate__Share];

Then I remove any exisitng Sharing Reasons (except for 'Owner'). To bring the sharing rules back down to Owner.

 

Then I generate a new Sharing Reason and append it to the share list and push it back up with:

 

 

		Database.Saveresult[] canShareInsertResult = Database.insert(candidateShares,false);

I'm debugging the entire process and here's what I see:

 

 

1. Step one: I change the candidate status to a non-employee status and the Employee Share Reason is generated fine.

2. Step two: I change the candidate status to employee and the Management Share Reason replaces the Employee Share Reason when I inspect the Debug Logs

3. Step three: When I inspect the sharing directly on the object from the salesforce site, it shows me that both reasons are now attached to the object

 

Is my problem inserting and not upserting?

 

 

In the To part of my send email page in VF below I want to be able to populate the input field with an email address that's recorded at {!Member__c.Email__c}  that someone has entered when creating a new record in my Member object.

 

Right now I have to manually type in an address. Everything works right and email gets sent but it's important that when sending email users don't need to type in this address. 

 

When I change the value for the inputText field in VF from value={!emailTo} to value={!Member__c.Email__c} the email address is shown but there is no valid To address to be able to send an email in mail.setToAddress so it fails.

 

Any help or ideas on this would be much appreciated!!

 

 

 

Apex

 

public class SendEmailPage {

    public SendEmailPage(ApexPages.StandardController controller) {
    }

public String emailTo {get; set;}
public String emailSubject {get; set;}
public String emailBody {get; set;}
public String response {get; set;}
 
public PageReference sendEmail(){

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

mail.setToAddresses(new String[] {emailTo});           
                                                
mail.setOrgWideEmailAddressId('0D2A0000000PBAC'); mail.setReplyTo('no-reply@company.com'); mail.setSubject(emailSubject); mail.setHtmlBody(emailBody); try{ Messaging.SendEmailResult[] resultMail = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); if(resultMail[0].isSuccess()) { PageReference page = System.Page.messagesent; page.setRedirect(true); return page; } else{ response = resultMail[0].getErrors().get(0).getMessage(); } }catch(System.EmailException ex){ response = ex.getMessage(); } return null; } }

 

 

VF Code

 

<apex:form >

To: <apex:outputField value="{!Member__c.Name}" /><br/>
<apex:inputText value="{!emailTo}" style="width: 200px"/><br/>

Subject:<br/>
<apex:inputtext value="{!emailSubject}" style="width: 400px"></apex:inputtext><br/><br/>

Body:<br/>
<apex:inputtextarea value="{!emailBody}" style="width: 400px; height: 100px"></apex:inputtextarea><br/>


<apex:commandbutton value="Send Message" action="{!sendEmail}" rerender="statusMail"></apex:commandbutton>
<apex:outputpanel id="statusMail" layout="block">
<strong><apex:outputtext value="{!response}"></apex:outputtext></strong>
</apex:outputpanel>
</apex:form>

 

 

 

 

  • May 25, 2010
  • Like
  • 0

I'm trying to setup a Sharing Reason and I'm having some issues.

 

Here are the steps and conditions I'm working with.

 

1. I'm working in the sandbox.

2. I have a custom object with a default sharing setting of "Private"

3. On my custom object, I created an Apex Sharing Reason. I created it by going to Setup > Create > Objects > My_Object__c and then adding a new Apex Sharing Reason

 

Now, I'm getting an "invalid share row cause" when I try the following in a Trigger

 

 

Candidate__Share managementShare = new Candidate__Share();
			managementShare.ParentId = can.Id;
			managementShare.UserOrGroupId = managementGroup.Id;
			managementShare.AccessLevel = 'edit';
			managementShare.RowCause = Schema.Candidate__Share.rowCause.Employee_Sharing_Reason;
			

 

 

What am I doing wrong? If I change the RowCause to:

 

 

Schema.Candidate__Share.RowCause.Owner

The error is gone but I'm not getting the share I want.

 

Hi,

I wrote an Apex triggers which update some custom field of Contacts. When I am trying to install the trigger in my sf account, it tries to create the Cutom fields on contact and if these fields are already present an error message pop-ups and installtion fails.

 

Could someone please suggest how I can by pass the creation of the custom fields on contact i.e. if fields are already present then do not create the same fields again during installation of package and also do not delete the fields during uninstallation of the package.

 

Please help me out. Thanks in advance for your reply.

Hi all,

 

I need to hide standard save and cancel button form custom page layout, is it possible if yes then how to do?

 

Can we write some javascript code in custom page layout?

 

 

Thanks

Hello.  On p. 420 of the 2008 Force.com Developers Guide (distributed at Dreamforce 2008), it says that "Message.sendMail method takes an array of messages to send, so you can send multiple messages in one single call."

 

Does this mean I can send an array of different email messages, each to a single recipient, in one call?  What is the syntax for constructing the array?  The documentation is not clear.

 

Here are the specifics of my situation: I need to send an email containing a personalized URL to several people, and I can't use merge fields/templates because the people's data are stored in a custom object, not in the Contact object.

 

Thanks

David

Hi,

 

I need to create a pdf file and insert it to the attachment object as record. This would fire as a scheduled class and not on a button click in a Visualforce page.

The code is as below:

 

global class OrderDispatchToTopcall implements Schedulable{
/*
        Author            : Cognizant
        Functionality     : This is a helper class is for the creation of the Order Dispatch pdf file and attach to the batch object.
                            The class acts as a controller class for the pdf generation.
                            Fetches data from the objects like Purchase order, Job Elements, Supplier
        Create Date       : 15 May 2010
        Change History    :
        Modified Date     :
    */
global void execute(SchedulableContext SC) {
PageReference pdf =  Page.MerchantDeliveryChecklist;
     pdf.getParameters().put('id', 'a1CR000000044H8');
     pdf.getParameters().put('pageType', 'NCHODC');
     pdf.setRedirect(true);
     Blob b=pdf.getContentAsPDF();
    
     Attachment attachment=new Attachment(ParentId='a1CR000000044H8',body=b,ContentType='application/pdf',Name='test.pdf');
     insert  attachment;
}
}

global class OrderDispatchToTopcall implements Schedulable{

 global void execute(SchedulableContext SC) {

 PageReference pdf =  Page.MerchantDeliveryChecklist;    

pdf.getParameters().put('id', 'a1CR000000044H8');    

 pdf.getParameters().put('pageType', 'NCHODC');    

 pdf.setRedirect(true);    

 Blob b=pdf.getContentAsPDF();      

  Attachment attachment=new Attachment(ParentId='a1CR000000044H8',body=b,ContentType='application/pdf',Name='test.pdf');    

insert  attachment;

 }

}

 

When this class runs it creates an attachment record but it is in a invalid format.

But when I call the same PDF creation code from button on a visualforce page, the attachment is created and it is a valid file.

 

Can somebody help me why I am not able to create a valid pdf file when the code runs from a schedular

 

I have a requirement to create a trigger that runs on the CaseComment object and does a string replacement on the contents of the comment body.

 

I need this trigger to modify CaseComments belonging to Cases of only 1 record type.

 

In order to do this, I have to check the RecordTypeId field of each CaseComment's parent Case. I'm having trouble figuring out how to do this without placing a SOQL query inside of the trigger.new for loop. I've tried two different methods:

 

   This method uses a single query to pull ALL the cases from the DB that match the RecordTypeID, then checks to see if each CaseComment matches one of those cases.

 

 

ID myCaseId = '0120000000095y7';
	//Fetch all needed Cases from the database
	List<Case> cases = [SELECT Id FROM Case WHERE RecordTypeId = :myCaseId];
	
	//For all new CaseComments,
	for(CaseComment c : trigger.new) {
		//Iterate through the cases
		for(Case c : cases) {
			//if this CaseComment matches a selected case 
			if(e.ParentID == c.Id) {
							
				//make the replacement........

 This doesn't work because I have 500+ cases and the governer limit stops me.

 

 

 

The second thing I tried to do was query the RecordTypeId of the CaseComment's parent Case directly via the relationship between them. (CaseComment.Parent.RecordTypeId)

 

        //PTI Support Case RecordTypeID
	ID myCaseId = '0120000000095y7';
	
	for(CaseComment comm : trigger.new) {

		if(comm.Parent.RecordTypeId == myCaseId) {
			//make the replacement...
		

 

 

This doesn't work because the relationship returns "null" for the RecordTypeId.

 

The trigger is running before update.

 

Does anyone have a solution to this?

Hi everyone,

 

Opportunity object is set to private for my organization and the owner of an opportunity can share it with other users.

When this owner transfer his opportunity to another user, all the old sharing rules are deleted, i need to keep those rules.

 

I first tought to keep the shareTable lines before the opportunity update but it doesn't seem to go anywhere.

Then i tought to disable the deleted rule in the share Table when the owner of the opportunity change but i can't figure out how to to that...

 

I'm stuck with this problem :(

 

Any help would be very appreciated...

 

Alex

Hello

I am using SF Soap API

I would like to add carriage return line feed in a long text area

I have tried  <urn1:Log__c>value1\nvalue2</urn1:Log__c> or <urn1:Log__c>value1\r\nvalue2</urn1:Log__c>

And when I go to SF there is no carriage return but \n or \n\r instead of carriage return

What is the solution ?

Thanks for your help

regards

Hi Im re-writing a page layout in VF for a particular recordtype.. How do I get the picklist values for some of the dropdowns to only show values for the recordtype I am building the page for?

Right now everything shows...

Thanks

 

I am developing a Visual force page for endering a pdf file, with the VF page i want to put in IF Condition, but am facing couple of problem. i would like to check the oppty line item value to diplay the total price

 

My If statement is;

<apex:OutputField value="{!IF((!line.Bill__c="VC"),{!line.TotalPrice},null)}"/>

 

My table code is

<apex:repeat value="{!Opportunity.OpportunityLineItems}" var="line">
          <tr>
             <td>{!line.PricebookEntry.Name}</td>
             <td>{!line.PricebookEntry.Product2.Status__c}</td>             
             <td>{!line.Quantity}</td>
             <td><apex:OutputField value="{!line.UnitPrice}"/></td>
             <td><apex:OutputField value="{!IF((!line.Bill__c="VC"),{!line.TotalPrice},null)}"/></td>
             <td><apex:OutputField value="{!IF((!line.Bill__c="FC"),{!line.TotalPrice},null)}"/></td>

          </tr>
       </apex:repeat>

 

Please let me know how to fix this issue.

Hello all,

 

I need to create two new leads when an Opportunity is closed-won and map over some date from Opp to the new leads.

I am a newbie to Apex programming and any pointers how to do this is really appreciated.

 

Thanks much,

VK86

  • May 14, 2010
  • Like
  • 0

I have a field that I want to be 90% controlled by some APEX code - but I still want the user to be able to select 1 value. All other values would be set by the code.

 

The issue I"m having is setting a validation rule that will either be ignored when updated via the trigger/class or have the Trigger/Class simply ignore the validation rule.

 

I thought I could get this by using "Without Sharing" but I must have mis understood that function.

 

Any thoughts? The closest I got is to put a hidden field that gets turned on by the trigger to ignore the validation, and then have a workflow or an after trigger than turns that field back off. Seems a bit much.

I've got a visualforce email template we use to send detailed information to our clients. However my users would like to be able to type/edit the email body before sending so they can include additional information. Most templates allow this, but the VF template is read only. Is it possible to allow editing before sending? Probably something simple I'm missing. Thanks. Mark

I am curious if anyone has built any systems that would monitor whether email was being successfully delivered from Salesforce.

I've begun playing with Visualforce, and I came across something that I haven't been able to figure out, although it seems to me I've got to be missing something pretty obvious.  I want to have an inputField span across two columns, just like on a page layout where the section is set to only have one column.  I haven't been able to reproduce this effect in Visualforce.  I assumed there might be a parameter on the pageBlockSection, or even the inputField, but based on the documentation I am not seeing it.  The only place I saw a mention of column spanning was with the column tag, which only works with the dataTable tag, which isn't for an input form.  I also looked at the panelGrid tag, and couldn't see a way of doing this with it either.
 
Thanks for any assistance.
 
Jon
 
 
Code:
<apex:page standardController="Sample_Request__c">
 <apex:sectionHeader title="New Sample Request" subtitle="Step 1 of 3"/>
 <apex:form>
  <apex:pageBlock title="Sample Information">
   <apex:pageBlockSection title="Ship To Address for Sample" columns="1" collapsible="false">
    <apex:inputField id="addressLine1" value="{!Sample_Request__c.Address_Line_1__c}"/>
    <apex:inputField id="addressLine2" value="{!Sample_Request__c.Address_Line_2__c}"/>
    <apex:inputField id="addressLine3" value="{!Sample_Request__c.Address_Line_3__c}"/>
    <apex:inputField id="addressLine4" value="{!Sample_Request__c.Address_Line_4__c}"/>
   </apex:pageBlockSection>
  </apex:pageBlock>
 </apex:form>
</apex:page>