• LauraBTN
  • NEWBIE
  • 5 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 2
    Replies
I think I am punch drunk.

I am trying to prevent a user from adding a new record in a child related list when the status of the parent record is locked -

I created a formula field to bring the status value down to the Child object - it is CampaignStatusValue__c

AND ( ISNEW(Giveaway_Quantity__c ), CampaignStatusValue__c  = "LOCKED")

I keep getting: Error: Incorrect number of parameters for function 'ISNEW()'. Expected 0, received 1


Any help would be greatly appreciated



I am a true newbie in the Trigger world - I have this trigger I pulled together that works well when you are only checking Personal account types - has issues with Business accounts - I need to modify it so it will run only on Personal Accounts.  I have a custom field that I populate with (FirstName, LastName and Phone) to check for duplicates.  Would appreciate any help given:

Trigger:
trigger accountDuplicateFullNamePreventer on Account (before insert, before update) {

Map<String, Account> accountMap = new Map<String, Account>();
for (Account account : System.Trigger.New) {

// Make sure we don't treat an FullName__c  that
// isn't changing during an update as a duplicate.

if ((account.FullName__c !=null) && (System.Trigger.isInsert || (account.FullName__c != System.Trigger.oldMap.get(account.Id).FullName__c))) {
//make sure another new account isn't also a duplicate
if (accountMap.containsKey(account.FullName__c)) {

account.FullName__c.addError('Another new account has the '
+ 'same Name.');

} else {
accountMap.put(account.FullName__c, account);
}
}
}
//Using a single database query, find all the accounts in
//the database that have the same FullName as any
// of the accounts being inserted or updated.

for (Account account : [SELECT FullName__c FROM Account WHERE FullName__c IN :accountMap.KeySet()]) {
Account newAccount=accountMap.get(account.FullName__c);
newAccount.FullName__c.addError('An account with this Name and Phone Number already exists.');
}
}