Table of Contents

Get identity by personal number (externalCode)

This script finds identity based on its personal number (externalCode).

This is useful as a transformation script for the required field "identity" = Owner (IdmIdentity - Id or username) when you synchronize contracts from some source system, where the owner is defined only by the personalnumber.

Script

import eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto;
import eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter;
import java.util.List;
 
if (attributeValue == null || attributeValue == "") {
    return null;
}
 
String externalCode = null;
if (attributeValue == null || attributeValue instanceof String) {
    externalCode = attributeValue;
} else {
    externalCode = attributeValue.toString();
}
IdmIdentityFilter filter = new IdmIdentityFilter();
filter.setExternalCode(externalCode);
//
List identities = identityService.findIds(filter, null).getContent();
if (identities != null && !identities.isEmpty()) {
    return identities.get(0).toString();
}
return null;

Script authorities

Service

identityService

Class

eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter

eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto

org.springframework.data.domain.PageImpl