19626
2023-10-31 fd9df05c48c09b4d7f39a3b401882bda226dedea
force-app/main/default/classes/OpportunityLightingButtonController.cls
@@ -4,7 +4,7 @@
 * @Author: chen jing wu
 * @Date: 2023-04-12 11:16:07
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-10-19 16:29:00
 * @LastEditTime: 2023-10-26 20:30:06
 */
public with sharing class OpportunityLightingButtonController {
    @AuraEnabled
@@ -600,7 +600,7 @@
            update opp;
            return null;
        } catch (Exception e) {
            return e.getDmlMessage(0);
            return errorMessage(e);
        }
    }
    @AuraEnabled
@@ -612,7 +612,7 @@
            update opp;
            return null;
        } catch (Exception e) {
            return e.getDmlMessage(0);
            return errorMessage(e);
        }
    }
    @AuraEnabled
@@ -626,7 +626,7 @@
            update opp;
            return null;
        } catch (Exception e) {
            return e.getDmlMessage(0);
            return errorMessage(e);
        }
    }
    @AuraEnabled
@@ -642,7 +642,7 @@
            update opp;
            return null;
        } catch (Exception e) {
            return e.getDmlMessage(0);
            return errorMessage(e);
        }
    }
    @AuraEnabled
@@ -772,7 +772,7 @@
            processResults.add(Approval.process(request));
            return processResults[0].errors;
        } catch (Exception e) {
            return e.getDmlMessage(0);
            return errorMessage(e);
        }
    }
    @AuraEnabled
@@ -786,7 +786,18 @@
            ];
            return user.Id;
        } catch (Exception e) {
            return e.getDmlMessage(0);
            if (e.getMessage().contains(',')) {
                System.debug(LoggingLevel.INFO, '*** e: ' + e);
                String exc = '' + e.getMessage();
                Integer left = exc.indexOf(':') + 1;
                Integer right = exc.lastIndexOf(':');
                String str = exc.substring(left,right);
                left = str.indexOf(',') +  1;
                String newStr = str.substring(left);
                return newStr;
            }else {
                return e.getMessage();
            }
        }
    }
    @AuraEnabled
@@ -800,7 +811,18 @@
            ];
            return pro.Id;
        } catch (Exception e) {
            return e.getDmlMessage(0);
            if (e.getMessage().contains(',')) {
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            String exc = '' + e.getMessage();
            Integer left = exc.indexOf(':') + 1;
            Integer right = exc.lastIndexOf(':');
            String str = exc.substring(left,right);
            left = str.indexOf(',') +  1;
            String newStr = str.substring(left);
            return newStr;
         }else {
            return e.getMessage();
         }
        }
    }
    @AuraEnabled
@@ -945,7 +967,7 @@
            return '1';     
        } catch (Exception ex) {
            Database.rollback(sp);
            return ex.getDmlMessage(0);
            return errorMessage(ex);
        }
    }
    @AuraEnabled
@@ -968,6 +990,21 @@
        return false;
    }
    public static string errorMessage(Exception e){
        if (e.getMessage().contains(',')) {
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            String exc = '' + e.getMessage();
            Integer left = exc.indexOf(':') + 1;
            Integer right = exc.lastIndexOf(':');
            String str = exc.substring(left,right);
            left = str.indexOf(',') +  1;
            String newStr = str.substring(left);
            return newStr;
        }else {
            return e.getMessage();
        }
    }
    public class InitData{
        @AuraEnabled
        public Boolean directLossFLG;