You need to sign in to do that
Don't have an account?
Michael Minnekeer
How can I increment field per ParentId(same way assignment rules auto calculate order)
As the title suggests I just want it so that on insert/save/delete a number field on a custom object auto calculates all records with the same parent Id from 1 to n where n is the size of the list of records with same parentId. The best example I can give is assignment rules in Salesforce as this behaviour is the exact thing I need.
I am unsure how to refer to the previous record value in a list to keep incrementing the integer. This field needs to be updatable so autonumbering is out of the question. Also I was hoping this to be a solution that contains no error messages so that if a user is inserting 2 records with the same value it auto calculates that (the user is inserting these records via add row visualforce solution so on save it updates a list).
I am unsure if this method is on the right track because if I need to change the value of the record in trigger.new I cannot update it again in the same transaction with before or after trigger.
I am unsure how to refer to the previous record value in a list to keep incrementing the integer. This field needs to be updatable so autonumbering is out of the question. Also I was hoping this to be a solution that contains no error messages so that if a user is inserting 2 records with the same value it auto calculates that (the user is inserting these records via add row visualforce solution so on save it updates a list).
I am unsure if this method is on the right track because if I need to change the value of the record in trigger.new I cannot update it again in the same transaction with before or after trigger.
public static void checkpriority(Client_Personal_Goal__c[] cgoals){ list<Client_Personal_Goal__c> existingcgoal = new list<Client_Personal_Goal__c>(); Set<Id> preclaraId = new set<Id>(); for(Client_Personal_Goal__c cgoal : cgoals){ preclaraId.add(cgoal.Related_Pre_Clarification__c); } existingcgoal = [select Id, Priority__c from Client_Personal_Goal__c where Related_Pre_Clarification__c in: preclaraId ORDER BY Priority__c ASC]; for(Client_Personal_Goal__c cgoal : existingcgoal){ //increment all values again? } try{ if(existingcgoal != null && existingcgoal.size() > 0 ){ update existingcgoal; } }catch(exception e){} }
Try the below code You are getting the above error method does not exist or invalid signature because in the below line of code You are not specifying the key.
So the reason it's throwing you an error method does not exist or invalid signature.
Please pass the key in the above line and compile the code you will be able to do it.
Please mark this post as solved if it helps.
Best Regards,
Nagendra.P