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
Fayyad ZahidFayyad Zahid 

Access Case on creation with certain Fields

Hello,
I am quite new to Salesforce and Apex (however I am very familiar with Java), so any help explained in simple terms would be much appreciated.

I am trying to write an Apex Trigger that will simply get the fields (shown below) of a Case on its creation. The fields I am trying to access are:

caseRecord, caseOwner, contactName, accountName, products, priority, status, caseOrigin, customerType, date/timeOpened, ticketDesc, subject, originator, reporter, primaryVendor, secondaryVendor, vendorStatus, createdBy, lastModifiedBy

I believe some of the fields may be custom fields, so I am also wondering how I would get those fields.

I would also like to get any attachments, related cases, and comments on the case, so if someone could tell me how I can access those, that would be very helpful.

 Thanks in advance to anyone who puts in the time to help answer my question!

Fayyad

 
Daniel Zeidler (DZ)Daniel Zeidler (DZ)
I'd recomend going over the trailhead module on triggers to understand how to access the Case fields: https://trailhead.salesforce.com/en/content/learn/modules/apex_triggers/apex_triggers_intro

To query the related records, I'd recomend checking out the Write SOQL of the Apex & Database trailhead module. (https://trailhead.salesforce.com/content/learn/modules/apex_database/apex_database_soql)

When working in Apex, you need to reference the fields by their API name. You can find the API names by going to the Salesforce setup page. The exact location in Setup will depend on whether you are using the Classic or Lightning interface.