• AntonyasLen
  • NEWBIE
  • 100 Points
  • Member since 2012

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 33
    Questions
  • 84
    Replies

Hi,

 

I wanted to know if it's possible to set a system var/value to use it in all my classes.

I'm thinking about a field who will be a "system field" !

 

******

info:

Special discount (percent)

T is a period of Time (1 month -2 months - 1years who know)

****

 

I have to use this special discount in a lot of case but i don't want to set it "manually" in my classe because i want to allow my CEO to go trought the CRM settings to update this value when he have to do it!

 

Does anyone have any idea?

 

Hi,

 

I searched a lot of way to improve my code and so far it was working fine.
(around 6-7 classes)

 

I'm currently fightinh with  Strange class class, the validator stop with IF statement or Object creation...it's really crazy...

 

I wrote this post to ask to the community if any one got issues with the code coverage avout :

- IF statement

- Statement inside a loop ( IF inside a For ..)

- Items creation...

 

i found some idea on internet but i just improved my test from 10 to 23 % ...

 

Sincerely

Hi,

 

i have an issue with my sharing setthing.

 

Background:

 

You can see my roles settings :

 

I have a B2B France Agent who created an Account A and a Contact C so far no problem.

But here my ORGANIZATION IDE SHARING :

 

Account is Private and Contact is Controlled by Parent;

 

Now my B2B China Agent have to work with the same contact (because each team are not seeling the same kind of product.)

The strange fact is that my B2B China agent is able to see the Conctact C created by the B2B France Agent. It's look svery weird because the setting is set as "Private".

 

Now i'm looking for the best way to allow my B2B China  Agent to work with the same contact but these agent can't see the opportunity or work of each other .

 

Sincerely,

 

Antony

Hi,

 

i wanted to deploy a part of my work but i waste a few hour and it doesn't work.

I wrote some class who validate my apex code (class and triggers) and everythings is around 80 to 100%.

 

But when my IDE tried to deploy my work i kept got error.

The current one si that

System.DmlException: Insert failed First exception on rowx 0: UNABLE_TO_LOCK_ROW  unable to obtain exclusive access to this record.

 

 

and this error is the same for my test class;

I really to deploy some critrical features but i'm kind a lock.

Anyone can help me?:(

 

 

Hi,

 

I guess that i'm missing something about sharing settings but i can't find why it doesn't work.

I set a sharing setting on my campaign object to allow my Salesman to add leads to a campaign created by  their manager.

 

So i created my sharing rules with the setthings below:

 

Campaign: owned by members of    Role: B2B Manager
Share with                                               Role: B2B Agent
Campaign Access: Read/Write

 

but my user still can't see the button to add a lead to the campaign.

 

Does anyone can help me?

Sincerely

Hi,

 

I created a visual page rend as pdf to generate invoices (so far it's working pretty well).

I just got a problem with my text alignment, it's looks like the right alignment doesn't work.

I can't manage quote-invoices-everthing but i can't aligne my data (newbie sorry)

 

Here the extract from my code:

 

  <table style="text-align:right;">

	    <tr>

	    <td Style="width:38%;">
	
	    </td>
	    <td Style="color:#6e7277; face:Arial, Helvetica, sans-serif; font-size:12px; width:20%;">
		    	<apex:panelGrid columns="1" >
		                    <apex:outputText value=" Total Articles HT : " />
		        </apex:panelGrid>
		        
		        <apex:panelGrid columns="1" >
		                    <apex:outputText value=" Remise Exceptionnelle :     " />
		        </apex:panelGrid>
		        
		        <apex:panelGrid columns="1" >
		                    <apex:outputText value=" Frais de port HT : " />
		        </apex:panelGrid>
		        
		        <apex:panelGrid columns="1" >
		                    <apex:outputText value=" Total HT : " />
		        </apex:panelGrid>
		        
		        <apex:panelGrid columns="1" >
		                    <apex:outputText value=" TVA : " />
		        </apex:panelGrid>
		        
		        <apex:panelGrid columns="1" >
		                    <apex:outputText value=" Total TTC : " />
		        </apex:panelGrid>    
		         
		        <br/>
		        
		         <apex:panelGrid columns="1" >
		                    <apex:outputText value=" Acompte perçu réf: : " />
		        </apex:panelGrid>
		        
		        <apex:panelGrid columns="1" >
		                    <apex:outputText value=" Net à Payer : " />
		        </apex:panelGrid>  
		    </td>
	   
	    	<td Style="color:#6e7277; face:Arial, Helvetica, sans-serif; font-size:12px;width:27%;">
		   			<apex:panelGrid columns="1"  Style="color:#fffffa;">
		   						<apex:outputText value="blank"/> 
		            </apex:panelGrid>
		            
		            <apex:panelGrid columns="1" >
		            			<apex:outputText value="{!ROUND(Invoice__c.Global_Discount__c,0)}% "/>              
		            </apex:panelGrid>
		    
		           <apex:panelGrid columns="1"  Style="color:#fffffa;">
		   						<apex:outputText value="blank"/> 
		            </apex:panelGrid>
		            
		            
		            <apex:panelGrid columns="1"  Style="color:#fffffa;">
		   						<apex:outputText value="blank"/> 
		            </apex:panelGrid>
		            
		            <apex:panelGrid columns="1" >
		                        <apex:outputText value="{!Invoice__c.VTA_Perct__c}"/>               
		            </apex:panelGrid>
		
		           <apex:panelGrid columns="1"  Style="color:#fffffa;">
		   						<apex:outputText value="blank"/> 
		            </apex:panelGrid>
		            
		             <br/>
		    	 	 <apex:panelGrid columns="1">
		                  <apex:outputText value="{!Invoice__c.Reference_Name__c}"/>
		            </apex:panelGrid>
		
		          <apex:panelGrid columns="1"  Style="color:#fffffa;">
		   						<apex:outputText value="blank"/> 
		            </apex:panelGrid>
		       
		        </td>
	    <td Style="color:#6e7277; face:Arial, Helvetica, sans-serif; font-size:12px;width:15%;align:right;">
	   			<apex:panelGrid columns="1"  >
	                        <apex:outputText value="{!ROUND(Invoice__c.Invoice_Total_HT__c,2)}"/>
	            </apex:panelGrid>
	            
	            <apex:panelGrid columns="1" >
	            			
	                        <apex:outputText value="{!ROUND(Invoice__c.Global_Discount_value__c,2)}"/>
	            </apex:panelGrid>
	    
	            <apex:panelGrid columns="1" >
	                        <apex:outputText value="{!ROUND(Invoice__c.Delivery_Cost__c,2)}"/>
	            </apex:panelGrid>
	            
	            
	            <apex:panelGrid columns="1" >
	                    <apex:outputText value="{!ROUND(Invoice__c.Grand_Total_HT__c,2)}" />
	            </apex:panelGrid>
	            
	            <apex:panelGrid columns="1" >
	          				
	                        <apex:outputText value="{!ROUND(Invoice__c.VTA_Value__c,2)}"/>
	            </apex:panelGrid>
	
	            <apex:panelGrid columns="1" >
	                        <apex:outputText value="{!ROUND(Invoice__c.Total_TTC__c,2)}" />
	            </apex:panelGrid>
	            
	            <br/>
	    	  	<apex:panelGrid columns="1" >
	                        <apex:outputText value="{!ROUND(Invoice__c.Balance_in_favour__c,2)}"/>
	            </apex:panelGrid>
	
	            <apex:panelGrid columns="1"  >
	                        <apex:outputText value="{!ROUND(Invoice__c.Net_Amount_due__c,2)}" />
	            </apex:panelGrid>
	       
	        </td>
	    </tr>
    
    </table>

 Here the result:

 

Dear community please help me,

Hi dear community,

 

I have a big issue with my product URL when i will add a product to an opportunity i have a trigger who will get the url of my product image.

 

The problem i that the Url field is limited to 255 so i was thinking about using a Long Text Area field but if i'm using the Long Text Area i can't do any preview using a Formula with a  Return Type equal to Text (using rthe IMAGE() function) formula looks like doesn't work with it.

 

So i tried to find a solution but it looks like i kind find any .

Does anyone can help?

Thanks,

 

 

 

Hi,

 

I created an invoice generator who is working fine.(by clicking on a button)

But i want to attach a pdf for every invoices to their master opportunity.(by clicking on a button)

I tried with one page layout and it's was working well, but i need to do it more dynamically.


Every invoices have a field called 'Layout_Number__c' who is a picklist field  set during the creation of the invoice (corresponding to a page name).

 

Here  my code :

public class TestAttachInvoices {

	
	ApexPages.StandardController controller;
	
	public Opportunity opp;

	
	public TestAttachInvoices(ApexPages.StandardController controller)
	{
		this.opp = (Opportunity)controller.getRecord();
		
	}
	
	public PageReference savePdf(){
		List<Invoice__c> invList = [Select id,Invoice_Name__c,Name,Layout_Number__c
									from Invoice__c
									Where Opportunity__c = :opp.id
									and Generated__c = false];
		for( Invoice__c invItem : invList ){
			pdfInvoices(invItem);
		}
		return new PageReference('javascript&colon;window.close()'); 
	}
	public static void pdfInvoices(Invoice__c inv){
		
		
		
		//Pagereference pdfPage = Page.InvoiceDeliveryA;  -> this was working well
		Pagereference pdfPage = Page.+inv.Layout_Number__c; // generating the error
		
		pdfPage.getParameters().put('Id',inv.id);
		
		//the contents of the attachment from my pdf
		Blob pdfBlob;

		try{
			
			pdfBlob = pdfPage.getContentAsPDF();
			
		}catch(VisualforceException e){
			system.debug(e);
			pdfBlob = Blob.valueOf('error');
		}
		
		Attachment attach = new Attachment(parentId = inv.id, name= inv.Name + '.pdf', body = pdfBlob);
		attach.IsPrivate = false;
		
		try{
			insert attach;
			inv.Generated__c = true;
			update inv;
		}
		 catch(DmlException d){
			d.getMessage();
		}
	}

}

 Here the error:

                                      error: You have attempted to reach a URL that no longer exists on salesforce.com.

 

 

Does anyone can help me?

Thanks,

 

edit: i tried to set as Pagereference pdfPage = Page.+inv.Layout_Number__c; but it still doesn't work =(

 

Hi,

 

*****************************************************************************************************************************************************************************************

Background:

 

I have created a custom object called Invoice, and all my invoices have a master details relation with the Opportunity object.

When an invoices is created i set a trigger to auto attach my pdf to the invoice's opportunity .

I use the same code as i use for my quote (except that for the quote salesman are clicking to attache the pdf) here i need to make it automatic .

 

*****************************************************************************************************************************************************************************************

 

So far it's looks like working except that i'm not able to open my pdf ,i got the following error :

                                                                           

                                                                                 file does not start by '%PDF-' 

 

Here my code :

 

Trigger:

trigger AttachInvoices on Invoice__c (after insert) {

	for(Invoice__c inv : Trigger.new){
		//TestAttachInvoices.savePdf(inv.Id);
		TestAttachInvoices.savePdf(inv);
	}
}

 

 

Class:

 

public class TestAttachInvoices {


	public static void savePdf(Invoice__c inv){
	
		
			 Pagereference pdfPage = Page.InvoiceDeliveryA;
		
		pdfPage.getParameters().put('Id',inv.id);
		
		//the contents of the attachment from my pdf
		Blob pdfBlob;

		try{
			
			pdfBlob = pdfPage.getContent();
			
		}catch(VisualforceException e){
			pdfBlob = Blob.valueOf('error');
		}
		
		Attachment attach = new Attachment(parentId = inv.id, name= inv.Name + '.pdf', body = pdfBlob);
		attach.IsPrivate = false;
		
		try{
			insert attach;
		}
		 catch(DmlException d){
			d.getMessage();
		}
	 
	}

}

 does anyone can help me ? =(

Dear community,

 

I have a class called by a button into my opportunity who will create an order in our website.

It's working pretty well, but i had to add a check function who will check if the product are in stock.(this function isn't a problem)

 

If one of the opportunity line item is not in stock (by the checking process) i just want to display a message to say "The products below arent in stock : id 1234 id 2569 ....." and don't allow the class to keep working( as a break point).


What is the best way to do it? i didn't understand the add.error method.

 

 

Sincerely,

Antony

Hi,

 

We decided to use the php tool kit to exchange information between Salesforce and our e-comerce website.

I can push my product into salesforce it's working pretty good, but i wanted to set as "isActive = false" a product and also set the product prices as "isActive =false" we got the following error:

 

[ERROR] INVALID_FIELD_FOR_INSERT_UPDATE : Unable to create/update fields: Pricebook2Id, Product2Id. Please check the security settings of this field and verify that it is read/write for your profile or permission set

 Does anyone can help us?

 

Thanks,

 

 

Dear community,

 

********************************************************************************************

Background:

 

I created a visualforce page for my Quote to get it as pdf.

So far it's working but i got an issue with my QuoteLineItems.( design problem)

********************************************************************************************

In my code i used the apex:repeatas you can see below :

 

 <apex:repeat value="{!Quote.QuoteLineItems}" var="line">
                        <tbody id="lineItem">
                           ****Quote Line Items information are displayed here ****
                        </tbody>
                        
</apex:repeat>  

 The problem come from the number of Quote Line Items, if have two or less items it's fine :

(all the informations are fake information from my sandbox)

 

 

 

Between two and five there is a problem for the price summary:

(all the informations are fake information from my sandbox)

 

With 5 items i don't have any problem :

 

and more than 5 my Quote Line item's tab is dirty:

(all the informations are fake information from my sandbox)

 

I'm not very skilled with this kind of design, so my questions are;

 

Should i created different page depend of the number of my quote line items?
Can we make a count on the visualforce page using apex?

I'm kind a lost .

 

Sincerely,

 

 

Hi,

 

My coworker can't connect himeself to our sandbox ( using php toolkit).

but he got this error :

 

INVALID_LOGIN: Invalid username, password, security token; or user locked out.

 

 

I reset the token - set the a new password and sent to him the informations and and the WSDL (enterprise) but he still can't connect himself.

Also i was able to see when i tried to connect himself by checking on the Login history but know i can't see anything :/....

 

 

I'm really lost ...=s

 

 

 

Hi,

 

i created some Triggers/Classe and i want to launch them by clicking on a button so far it's working by using a VF page who is calling my classes. The issue s that i want to know how to forbib my classes to be launched in some case ( for the example a boolean who is false).

 

Someone told me about using javascript but i'm pretty bad and it's kind a mess for me ...

 

Does anyone can help me??( if you can give me a strong exemple it would be awesome

 

Thanks

Hi,

 

Well, i'll try to be very clear, please let me my explanation are weird

 

****************************************************************************************************

Background:

 

The Opportunity is the main object of my salesman's work-in-process.

I created  a custom object called Payment( the amount of an opportunity can be split in a few payment)

 

I created a custom object called Invoice, invoices have two different type : Deposit - Delivery .

Each Invoice type has a different visual force page( so far 2 template).

 

I want to create and attach .pdf to my Opportunity ( i know how to do it i done it for the quote object ), but the hard my problem is that i want to create the .pdf with Invoices datas and also the deposit and delivery invoices will not be created at the same time.

This have to be automatic.

 

- Deposit invoice are created when i will set a Payment as a deposit.

- Delivery invoices will be generated when the customer order will be delivered ( manual set).

 

 

****************************************************************************************************

 

Does anyone can help me to define the best process ?

 

 

edit: here an other to as my  question.....

can i make a visual force page(rend as pdf) but attach it to the master opportuntity???

 

Hi everybody,

 

My opportunity has a master-detail to a custom object called Opportunity.

i tried this

<apex:repeat value="{!Opportunity.Payment__c}" var="line"

 

but it's not working.

Anyone?

 

Hi,

i have created the flow below:

 

With this flows i'll allow the salesman manager to create special product from an opportunity when he need it.

So far it's working, i just wanted to know how can i do to exit the window when i'm clicking on "Finish" on my final screen.

Thanks

Hi,

 

i have a custom field called "url" on Product2 i just want to set it to my OpportunitLineItem when i'll add one to my opportunity.

i wrote the trigger below:

 

trigger SetSpecialProductInfo on OpportunityLineItem (before insert) {
    for(OpportunityLineItem op : Trigger.new){
    	if(op.Id_uad__c == 0){
    		String url = [Select URL__c From Product2 Where Id = :op.PricebookEntry.Product2Id limit 1];
			op.Image_Url__c = url;
			update op;
    	}
    }
}

i got this error: Save error: Illegal assignment from LIST<Product2> to String

i was thinking that if i use the "limit 1" i'll prevent the multiple result but it looks like doesn't work =/

 

Thanks

Hi,

 

***********************************************************************************************************************

 

Background:

 

Every product has a delivery man (look up) to this product.

When the salesman will add an Opportunity Product he will have to add a delivery man to the Opportunity Product.

But i wanted to pre-populate the Develiry man with the Product2 value.

 

***********************************************************************************************************************

i was thinking that using trigger "Before insert" would help me but i was wrong.


Dear community do you have any idea?

Hi,

 

******************************************************************************

Background:

 

Every product have a default carrier(look up) and a list of authorized carrier(list).

My salesman will be able to choose a carrier for the Opportunity Product even if the carrier isn't in the product authorized carrier by a lookup.

 

******************************************************************************

 

In that case i want to show a message to the salesman as  "for the some product you didn't choose authorized carriers, please make sure to check the delivery costs with de logistics".

 

I know that i can check my criteria with a Trigger or using Workflow rules/and/ CheckBox.
But my question is about the best way to show up this message. i made a research but i didn't really understand.

 

-also-

 

I wanted to know if it's possible to generate a pop-up when my user is going to work on an Opportunity X.

My idea is, to show every product + carrier for the product everytimes when the user go to see this opportunity except if my salesman check "i understood - or - don't show me this message again."

 

 

Thanks dear developers 

 

Hi,

 

I wanted to know if it's possible to set a system var/value to use it in all my classes.

I'm thinking about a field who will be a "system field" !

 

******

info:

Special discount (percent)

T is a period of Time (1 month -2 months - 1years who know)

****

 

I have to use this special discount in a lot of case but i don't want to set it "manually" in my classe because i want to allow my CEO to go trought the CRM settings to update this value when he have to do it!

 

Does anyone have any idea?

 

Hi,

 

I searched a lot of way to improve my code and so far it was working fine.
(around 6-7 classes)

 

I'm currently fightinh with  Strange class class, the validator stop with IF statement or Object creation...it's really crazy...

 

I wrote this post to ask to the community if any one got issues with the code coverage avout :

- IF statement

- Statement inside a loop ( IF inside a For ..)

- Items creation...

 

i found some idea on internet but i just improved my test from 10 to 23 % ...

 

Sincerely

Hi,

 

i have an issue with my sharing setthing.

 

Background:

 

You can see my roles settings :

 

I have a B2B France Agent who created an Account A and a Contact C so far no problem.

But here my ORGANIZATION IDE SHARING :

 

Account is Private and Contact is Controlled by Parent;

 

Now my B2B China Agent have to work with the same contact (because each team are not seeling the same kind of product.)

The strange fact is that my B2B China agent is able to see the Conctact C created by the B2B France Agent. It's look svery weird because the setting is set as "Private".

 

Now i'm looking for the best way to allow my B2B China  Agent to work with the same contact but these agent can't see the opportunity or work of each other .

 

Sincerely,

 

Antony

Hi,

 

i wanted to deploy a part of my work but i waste a few hour and it doesn't work.

I wrote some class who validate my apex code (class and triggers) and everythings is around 80 to 100%.

 

But when my IDE tried to deploy my work i kept got error.

The current one si that

System.DmlException: Insert failed First exception on rowx 0: UNABLE_TO_LOCK_ROW  unable to obtain exclusive access to this record.

 

 

and this error is the same for my test class;

I really to deploy some critrical features but i'm kind a lock.

Anyone can help me?:(

 

 

Hi,

 

I created a visual page rend as pdf to generate invoices (so far it's working pretty well).

I just got a problem with my text alignment, it's looks like the right alignment doesn't work.

I can't manage quote-invoices-everthing but i can't aligne my data (newbie sorry)

 

Here the extract from my code:

 

  <table style="text-align:right;">

	    <tr>

	    <td Style="width:38%;">
	
	    </td>
	    <td Style="color:#6e7277; face:Arial, Helvetica, sans-serif; font-size:12px; width:20%;">
		    	<apex:panelGrid columns="1" >
		                    <apex:outputText value=" Total Articles HT : " />
		        </apex:panelGrid>
		        
		        <apex:panelGrid columns="1" >
		                    <apex:outputText value=" Remise Exceptionnelle :     " />
		        </apex:panelGrid>
		        
		        <apex:panelGrid columns="1" >
		                    <apex:outputText value=" Frais de port HT : " />
		        </apex:panelGrid>
		        
		        <apex:panelGrid columns="1" >
		                    <apex:outputText value=" Total HT : " />
		        </apex:panelGrid>
		        
		        <apex:panelGrid columns="1" >
		                    <apex:outputText value=" TVA : " />
		        </apex:panelGrid>
		        
		        <apex:panelGrid columns="1" >
		                    <apex:outputText value=" Total TTC : " />
		        </apex:panelGrid>    
		         
		        <br/>
		        
		         <apex:panelGrid columns="1" >
		                    <apex:outputText value=" Acompte perçu réf: : " />
		        </apex:panelGrid>
		        
		        <apex:panelGrid columns="1" >
		                    <apex:outputText value=" Net à Payer : " />
		        </apex:panelGrid>  
		    </td>
	   
	    	<td Style="color:#6e7277; face:Arial, Helvetica, sans-serif; font-size:12px;width:27%;">
		   			<apex:panelGrid columns="1"  Style="color:#fffffa;">
		   						<apex:outputText value="blank"/> 
		            </apex:panelGrid>
		            
		            <apex:panelGrid columns="1" >
		            			<apex:outputText value="{!ROUND(Invoice__c.Global_Discount__c,0)}% "/>              
		            </apex:panelGrid>
		    
		           <apex:panelGrid columns="1"  Style="color:#fffffa;">
		   						<apex:outputText value="blank"/> 
		            </apex:panelGrid>
		            
		            
		            <apex:panelGrid columns="1"  Style="color:#fffffa;">
		   						<apex:outputText value="blank"/> 
		            </apex:panelGrid>
		            
		            <apex:panelGrid columns="1" >
		                        <apex:outputText value="{!Invoice__c.VTA_Perct__c}"/>               
		            </apex:panelGrid>
		
		           <apex:panelGrid columns="1"  Style="color:#fffffa;">
		   						<apex:outputText value="blank"/> 
		            </apex:panelGrid>
		            
		             <br/>
		    	 	 <apex:panelGrid columns="1">
		                  <apex:outputText value="{!Invoice__c.Reference_Name__c}"/>
		            </apex:panelGrid>
		
		          <apex:panelGrid columns="1"  Style="color:#fffffa;">
		   						<apex:outputText value="blank"/> 
		            </apex:panelGrid>
		       
		        </td>
	    <td Style="color:#6e7277; face:Arial, Helvetica, sans-serif; font-size:12px;width:15%;align:right;">
	   			<apex:panelGrid columns="1"  >
	                        <apex:outputText value="{!ROUND(Invoice__c.Invoice_Total_HT__c,2)}"/>
	            </apex:panelGrid>
	            
	            <apex:panelGrid columns="1" >
	            			
	                        <apex:outputText value="{!ROUND(Invoice__c.Global_Discount_value__c,2)}"/>
	            </apex:panelGrid>
	    
	            <apex:panelGrid columns="1" >
	                        <apex:outputText value="{!ROUND(Invoice__c.Delivery_Cost__c,2)}"/>
	            </apex:panelGrid>
	            
	            
	            <apex:panelGrid columns="1" >
	                    <apex:outputText value="{!ROUND(Invoice__c.Grand_Total_HT__c,2)}" />
	            </apex:panelGrid>
	            
	            <apex:panelGrid columns="1" >
	          				
	                        <apex:outputText value="{!ROUND(Invoice__c.VTA_Value__c,2)}"/>
	            </apex:panelGrid>
	
	            <apex:panelGrid columns="1" >
	                        <apex:outputText value="{!ROUND(Invoice__c.Total_TTC__c,2)}" />
	            </apex:panelGrid>
	            
	            <br/>
	    	  	<apex:panelGrid columns="1" >
	                        <apex:outputText value="{!ROUND(Invoice__c.Balance_in_favour__c,2)}"/>
	            </apex:panelGrid>
	
	            <apex:panelGrid columns="1"  >
	                        <apex:outputText value="{!ROUND(Invoice__c.Net_Amount_due__c,2)}" />
	            </apex:panelGrid>
	       
	        </td>
	    </tr>
    
    </table>

 Here the result:

 

Dear community please help me,

Hi dear community,

 

I have a big issue with my product URL when i will add a product to an opportunity i have a trigger who will get the url of my product image.

 

The problem i that the Url field is limited to 255 so i was thinking about using a Long Text Area field but if i'm using the Long Text Area i can't do any preview using a Formula with a  Return Type equal to Text (using rthe IMAGE() function) formula looks like doesn't work with it.

 

So i tried to find a solution but it looks like i kind find any .

Does anyone can help?

Thanks,

 

 

 

Hi,

 

*****************************************************************************************************************************************************************************************

Background:

 

I have created a custom object called Invoice, and all my invoices have a master details relation with the Opportunity object.

When an invoices is created i set a trigger to auto attach my pdf to the invoice's opportunity .

I use the same code as i use for my quote (except that for the quote salesman are clicking to attache the pdf) here i need to make it automatic .

 

*****************************************************************************************************************************************************************************************

 

So far it's looks like working except that i'm not able to open my pdf ,i got the following error :

                                                                           

                                                                                 file does not start by '%PDF-' 

 

Here my code :

 

Trigger:

trigger AttachInvoices on Invoice__c (after insert) {

	for(Invoice__c inv : Trigger.new){
		//TestAttachInvoices.savePdf(inv.Id);
		TestAttachInvoices.savePdf(inv);
	}
}

 

 

Class:

 

public class TestAttachInvoices {


	public static void savePdf(Invoice__c inv){
	
		
			 Pagereference pdfPage = Page.InvoiceDeliveryA;
		
		pdfPage.getParameters().put('Id',inv.id);
		
		//the contents of the attachment from my pdf
		Blob pdfBlob;

		try{
			
			pdfBlob = pdfPage.getContent();
			
		}catch(VisualforceException e){
			pdfBlob = Blob.valueOf('error');
		}
		
		Attachment attach = new Attachment(parentId = inv.id, name= inv.Name + '.pdf', body = pdfBlob);
		attach.IsPrivate = false;
		
		try{
			insert attach;
		}
		 catch(DmlException d){
			d.getMessage();
		}
	 
	}

}

 does anyone can help me ? =(