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
Rohit kumar singh 1Rohit kumar singh 1 

Coding Query

trigger Customer_After_Insert on APEX_Customer__c (after update)
{
(*)List InvoiceList = new List();
for (APEX_Customer__c objCustomer: Trigger.new)
{
if (objCustomer.APEX_Customer_Status__c == 'Active')
{
APEX_Invoice__c objInvoice = new APEX_Invoice__c();
(*)objInvoice.APEX_Status__c = 'Pending';
(*) InvoiceList.add(objInvoice);
}
}
}
Can SomeOne Explain me the code flow speciall the "(*)"->Points
Best Answer chosen by Rohit kumar singh 1
FearNoneFearNone
hi Rohit,

You are right, those are custom objects. 
The tutorial should have written List<apex_invoice__c> InvoiceList to avoid confusion.

Let us do a reverse engineering here.
From what we see in the code, there are two custom objects: apex_invoice__c, APEX_Customer__c.
※ APEX_Customer__c has the following fields:
APEX_Customer_Status__c (picklist: you can put selection like 'Active', 'Not Active' ...)
※ apex_invoice__c has the following fields:
- APEX_Status__c (picklist: you can put selection like 'Pending', 'Approved' ...)

Then lastly is the 'insert InvoiceList' which will now store all the invoice data to the database...
 

All Answers

FearNoneFearNone
It would be better if you study and understand it first by yourself through google, then post the things that you want clarify based on what you understand.
https://trailhead.salesforce.com/en/apex_triggers/apex_triggers_intro

anyway, to answer your question for the meantime
The whole process means that when a customer-record is updated, invoice-records will be produced.
The (*)List InvoiceList = new List(); means the list of invoice-records.
Then, inside the loop, for every customer, an invoice is created an assigned it to 'Pending',
then the created invoice will be stored to invoice-records list.
Rohit kumar singh 1Rohit kumar singh 1
hey FearNone
Thanks For Helping but
I got this example from TutorialPoint.com  and I got confused. 
https://www.tutorialspoint.com/apex/apex_triggers.htm
First thing What is this " List Invoicelist=new Invoice List" i.e Where I can find this InvoiceList .
"APEX_Invoice__c objInvoice = new APEX_Invoice__c();" //What is this APEX_Invoice__c whether it is custom object or it is a field inside "APEX__Customer__c" custom object.

If it is a custome Object then "objInvoice.APEX_Status__c = 'Pending';" This is good I understood. 
But then again where i will find the output or Result of this " InvoiceList.add(objInvoice);"
Where is this Invoicelist.

Code is Ok I m facing problem with this Invoicelist and this Apex_Customer__c Object like How it is made with what all field and relationship.
FearNoneFearNone
hi Rohit,

You are right, those are custom objects. 
The tutorial should have written List<apex_invoice__c> InvoiceList to avoid confusion.

Let us do a reverse engineering here.
From what we see in the code, there are two custom objects: apex_invoice__c, APEX_Customer__c.
※ APEX_Customer__c has the following fields:
APEX_Customer_Status__c (picklist: you can put selection like 'Active', 'Not Active' ...)
※ apex_invoice__c has the following fields:
- APEX_Status__c (picklist: you can put selection like 'Pending', 'Approved' ...)

Then lastly is the 'insert InvoiceList' which will now store all the invoice data to the database...
 
This was selected as the best answer