Saturday, July 16, 2022

Convert Image to Base64 string in D365FO

 Convert Image to Base64 string in D365FO.

    HcmWorker           HcmWorker;
    HcmPersonImage      HcmPersonImage;
    ExecutePermission   perm;
    container           imgObj;
    BinData             bd;
    Notes               result;

    new InteropPermission(InteropKind::ClrInterop).assert();
    perm = new ExecutePermission();
    perm.assert();

    HcmWorker       = HcmWorker::findByPersonnelNumber('employeeId');
    HcmPersonImage  = HcmPersonImage::findByPerson(HcmWorker.Person);
    
    imgObj = HcmPersonImage.Image;
    bd = new BinData();
    bd.setData(imgObj);
    
    result = bd.base64Encode();
    //ssPermission::revertAssert();



Keep Daxing!!




No comments:

Post a Comment