function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Cynthia DouglassCynthia Douglass 

Creating a "Previous Balance" value for a current invoice

I asked this question for a prevous topic, but forgot to change the topic to be relevant to the questions (still new at this); sorry about that!

Using SF Professional Edition, would anyone know about to:

1) Create, on a custom object (Certification Invoice) page layout, a Related List section called Certification History, that lists all previous invoices for the custom field Exporter Company, if that field is filled in, or for the custom field Third Party Company, if the Exporter Company field is not filled in (either Third Party Company or Exporter Company will be filled in for every invoice; sometimes both will be filled in, but the Exporter Company information would be the priority for looking at Certification History).

2) Pull out the $ amount of the custom field Remaining Value (formula field) from the most recent invoice for the company listed in 1); and

3) Insert the value of 2) into my current invoice, into the custom field Previous Balance.

Here's what I've done so far, and there are 3 questions at the end of this rather lengthy description for anyone willing to take a look at this (I am learning that you developers like details!):

I have a custom app called Certification.

I have the following custom objects in the Certification app called:

- Certification Document - this brings in line items for the Certification Invoice object, showing # of documents, document destination, and subtotal for each set of documents going to the same destination.

- Certification Invoice - This is the main input form for our certification officers, and records all details necessary to process the certifying of commercial or legal documents, including payment details.

- Certification Receipt - This is as yet undefined, but I would like this to reflect many of the fields in the Certification Invoice, and it would be automatically filled in from the Certification Invoice when a custom button called Certify is clicked.

- Certification Type - This defines two types of documents for certification, either Commercial Documents or Legal Documents, and their price.

Here is how the Certification Invoice currently looks:
Certification Invoice
Within the object Certification Invoice I have two choices for companies/accounts: Exporter Company, or Third Party Company.  Both have lookup relationships to Accounts.  I created formula fields ("Company (Exporter)" and "Company (3rd party)" so that the lookup value of Exporter Company the Third Party Company would be a text result rather than a lookup value.

I then went into the custom Previous Invoice field, which has a lookup relationship with Certification Invoice.  Then I set up lookup filters to only look for previous invoices that matched either the name of the Exporter Company on the current Certification Invoice, or the name of the Third Party Company on the current Certification Invoice, with the default being the Exporter Company name if that was filled in.  In addition, the Certification Date+Time stamp of the current Certification Invoice must be greater than the Certification Date+Time stamp of the Previous Invoices.  That looks like this:
Previous Invoice lookup filters

This leaves me with a lookup list of invoices for the Exporter Company or 3rd Party Company ONLY, and once I pick which one from the list is the most current one, the Remaining Balance value from that Previous Invoice drops into the Previous Balance field of the current Certification Invoice.

QUESTION 1: My lookup filters have narrowed down the field considerably, but I'd still like to have the Previous Invoice specify not ALL of the previous invoices for the current Exporter Company or 3rd Party Company, but the most current one ONLY.  I've changed the Certification Invoice # to be a straight auto-generated #, and the Certification Date+Time stamp is also auto-generated.  How could I add another lookup filter that would do this?  Or is there another way?

QUESTION 2: How can I track the history of invoices for a particular company and put this information on this Certification Invoice page layout, specific to the Export Company or Third Party Company listed on this invoice?

QUESTION 3: Could certification history for the current invoice company be listed in the standard Related List called Certification Invoices?  If so, how would I set that up?  I've set up columns with relevant fields in the Related List section for Certification Invoices, but I don't know how to relate these fields to the previous invoice data.  Here's how it currently looks:
Related Lists: Cert. History
Thank you in advance for any assistance you may be able to share!

Best,

Cynthia