You need to sign in to do that
Don't have an account?
JJSHHS
DB trigger on the same object
Hello,
Had this dumb question. I can hear you telling that this can be done by setting up default values on the platform itself vs. a trigger and I'm completely trying the below as an experiment.
trigger spnInsert on Position__c (before Insert) {
For (Position p: trigger.new) {
p.Max_Pay__c = 99999;
}
}
I'm getting this error below.
Error: Compile Error: Invalid type: Position at line 3 column 10
When I tried changing the for loop to state, however, I'm getting a different error - trigger name is already used
For (Position__c p: trigger.new) {
3. I also tried the below one.
trigger spnInsert on Position__c (before Insert) {
list <position__c> p = new list <position__c>();
For (p : trigger.new) {
p.Max_Pay__c = 99999;
}
}
Pl advise, what am I missing here.
Had this dumb question. I can hear you telling that this can be done by setting up default values on the platform itself vs. a trigger and I'm completely trying the below as an experiment.
trigger spnInsert on Position__c (before Insert) {
For (Position p: trigger.new) {
p.Max_Pay__c = 99999;
}
}
I'm getting this error below.
Error: Compile Error: Invalid type: Position at line 3 column 10
When I tried changing the for loop to state, however, I'm getting a different error - trigger name is already used
For (Position__c p: trigger.new) {
3. I also tried the below one.
trigger spnInsert on Position__c (before Insert) {
list <position__c> p = new list <position__c>();
For (p : trigger.new) {
p.Max_Pay__c = 99999;
}
}
Pl advise, what am I missing here.
The blue dot means that you cant remove the field from the page layout.
All Answers
trigger spnInsert on Position__c (before Insert) {
For (Position__c p: trigger.new) {
p.Max_Pay__c = 99999;
}
}
The trigger name is already used might just have been an issue with the IDE as sometime you can do 2 saves at the same time.
there's no point in declaring a list (list <position__c> p = new list <position__c>();) as this list stay empty anyway.
The for loop structure should be as follow :
for(Type varName : iterable) { code }
so doing for(Position__c p : trigger.new) { p.Max_Pay__c = 99999; } is the way to go.
Thanks for your help. I was using the same "trigger name" within my dev org. However, within 2 different apps. But it's not working. When I changed the trigger name, it started to work.
One more question - when I look at custom object fields - using the field layout, how do I know which fields are required vs. not without having to go into every single field.
When you view the page layout you should see red asterixs next to the fields that are required.
There are two ways to require a field though, the first is to do at the database level and require it for every record. The other way is at the page level where it can be required on a specific page layout.
The blue dot means that you cant remove the field from the page layout.
Link to better sized screenshot