Thursday, January 13, 2022

Salesforce concept : Validation rule does not fired after approval process field update

Validation rule will not be fired by Workflow rule or Approval Process field update based on document.

Both API level and UI level change of record honored validation rule , but field update is an exception.

Which means , if you have an validation rule block field_ABC value to be "ABC", if you used a field update to do this, the value of  field_ABC can be set as "ABC".



Official IdeaExchange 1

"because updates to records based on workflow rules doesn't trigger validation rules,workflow rules can invalidate previously valid fields "


Official IdeaExchange 2




Wednesday, January 12, 2022

Salesforce Apex code to detect Chinese or Japanese characters 在字串中尋找漢字 包含中文字 或 日文字

 Sometimes we have to identify the language character inside string . Code below shows how to use Apex code to identify whether a specific string contains "Hanzi" or not . 

#Please be reminded that "Hanzi" NOT just detect Chinese characters , it may also include Japanese Hanzi.  

1
2
3
4
5
6
//true if contain chinese or japanese hanzi
public static Boolean containsChineseCharacters(String InputString){
    Pattern p = Pattern.compile('\\p{IsHan}');
    Matcher m = p.matcher( InputString );
    return m.find();
}

Tuesday, January 11, 2022

Copy files based on file list document 按照文件清單複製檔案 抄送

 Consider of a scenario, partner's SFTP server is down for an hour . A lots of files failed to upload to them.  After comparing the file list of two company, a missing file list text file has been created.
Maybe 100 out of 1000 files are missing.

Hence, you are going to resend those missing files based on the file list.
Batch script below help to do the job in an easy way.

You may just copy all missing files to a new folder, then resend.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
@ECHO ON


SET FileList=C:\Users\XXX\MissingFiles.txt
::The folder that contains the files
SET Source=X:\AllFiles
::The folder that the files should be copied to
SET Destination=Y:\ToBeResend

 

FOR /F "USEBACKQ TOKENS=*" %%F IN ("%FileList%") DO XCOPY /F /Y "%Source%\%%~F" "%Destination%\"

GOTO :EOF

 

Next year SF migration plan : moving out customer account to AWS , and call SF data with service account

 👀 The most challenging part is about those function with user verification. My service cloud with MIAW chat , nearly redo due to the user ...