To achieve this, you need to create a trigger on the Issue object that checks the Primary Issue checkbox field only for the first record created from a Case.
trigger IssueTrigger on Issue__c (after insert) {
Set<Id> caseIds = new Set<Id>();
for (Issue__c issue : Trigger.new) {
caseIds.add(issue.Case__c);
}
List<Case> cases = [SELECT Id, (SELECT Id, Primary_Issue__c FROM Issues__r ORDER BY CreatedDate ASC) FROM Case WHERE Id IN :caseIds];
List<Issue__c> issuesToUpdate = new List<Issue__c>();
for (Case c : cases) {
if (!c.Issues__r.isEmpty()) {
Issue__c firstIssue = c.Issues__r[0];
if (!firstIssue.Primary_Issue__c) {
firstIssue.Primary_Issue__c = true;
issuesToUpdate.add(firstIssue);
}
}
}
// Update the Issues
update issuesToUpdate;
}
This trigger will run after any new Issue is inserted and check if it is the first related Issue for its parent Case. If it is, it will set the Primary Issue checkbox to true. Otherwise, it will leave it as false.
Note: Change the object name, Field name and relationship name according to your org.