Friday, September 22, 2017

Add path delimiter for file paths in the field modified value

I found this really interesting way to make sure that the file paths have a forward slash in the end when modifying file paths is to add the following code in the table modified field method


public void modifiedField(FieldId _fieldId)
{
    #File
    super(_fieldId);

    switch (_fieldId)
    {
        (fieldNum(HcmSharedParameters, YourField )):
            // Remove leading and trailing whitespace
            this.(_fieldId) = strltrim(strrtrim(this.(_fieldId)));

            // Add trailing slash if missing
            if (this.(_fieldId) && substr(this.(_fieldId), strlen(this.(_fieldId)), 1) != #FilePathDelimiter)
            {
                this.(_fieldId) = this.(_fieldId) + #FilePathDelimiter;
            }
            break;
    }
}

No comments:

Post a Comment