• Joseph Dekis
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

Hello, I have been a bit perplexed by this issue and could use some help.  I have a method in before update trigger that is writing the changes of a changed field ( the field name, the oldvalue, and the newvalue) of a field changed within a fieldset.  

 

The output is just the first line which is "These fields are changed and need approval: " and then nothing else prints.  Also, debugging I find that I have this in a try/catch and I am seeing the "Error:  String validation Exception on name ID" which has me very confused as well. 

 

Here is the code 

 

public static void getChangedFieldValues(Map<Id, Account> newMap, Map<Id, Account> oldMap) {

        List<Schema.FieldSetMember> approvalFields = Util.getAddressApprovalFields();

        for (Account newAcc : newMap.values()) {
            Account oldAcc = oldMap.get(newAcc.Id);

            for (FieldSetMember fsm : approvalFields ) {
                String field = fsm.getFieldPath();
                try {
                    System.debug('newAcc.get(Field) ====== ' + newAcc.get(field));
                    System.debug('oldAcc.get(Field) ====== ' + oldAcc.get(field));
                    if (newAcc.get(field) != oldAcc.get(field)) {
                        newAcc.Start_Address_Approval_Description__c = 'These address fields are changed and need approval:\n';
                        newAcc.Start_Address_Approval_Description__c += fsm.getLabel() + ' changed from: ' + oldMap.get(fsm.getFieldPath()) + ' to: ' +
                                newAcc.get(fsm.getFieldPath()) + '\n';
                    }
                } catch (Exception e) {
                    System.debug('Address Error: ' + e);
                }
            }
}


Like i said, it is updating the Description field with the first line, "These address fields are changed and need approval" , but then nothing else is getting added to the field, and at the same time I am also seeing that weird error:

Error: System.StringException: Invalid id: Name

 

Any help on why the rest is not being printed or the error would help immensely.  

Hello, I have been a bit perplexed by this issue and could use some help.  I have a method in before update trigger that is writing the changes of a changed field ( the field name, the oldvalue, and the newvalue) of a field changed within a fieldset.  

 

The output is just the first line which is "These fields are changed and need approval: " and then nothing else prints.  Also, debugging I find that I have this in a try/catch and I am seeing the "Error:  String validation Exception on name ID" which has me very confused as well. 

 

Here is the code 

 

public static void getChangedFieldValues(Map<Id, Account> newMap, Map<Id, Account> oldMap) {

        List<Schema.FieldSetMember> approvalFields = Util.getAddressApprovalFields();

        for (Account newAcc : newMap.values()) {
            Account oldAcc = oldMap.get(newAcc.Id);

            for (FieldSetMember fsm : approvalFields ) {
                String field = fsm.getFieldPath();
                try {
                    System.debug('newAcc.get(Field) ====== ' + newAcc.get(field));
                    System.debug('oldAcc.get(Field) ====== ' + oldAcc.get(field));
                    if (newAcc.get(field) != oldAcc.get(field)) {
                        newAcc.Start_Address_Approval_Description__c = 'These address fields are changed and need approval:\n';
                        newAcc.Start_Address_Approval_Description__c += fsm.getLabel() + ' changed from: ' + oldMap.get(fsm.getFieldPath()) + ' to: ' +
                                newAcc.get(fsm.getFieldPath()) + '\n';
                    }
                } catch (Exception e) {
                    System.debug('Address Error: ' + e);
                }
            }
}


Like i said, it is updating the Description field with the first line, "These address fields are changed and need approval" , but then nothing else is getting added to the field, and at the same time I am also seeing that weird error:

Error: System.StringException: Invalid id: Name

 

Any help on why the rest is not being printed or the error would help immensely.