Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

LDAP Transform Script

MichaelS4451727
Tera Expert

Hello,

 

I am attempting to use a transform script to set the company field. I have verified I am getting the correct data through use of gs.log statements, but the value is not being filled in on the company field in the sys_user table. I am thinking it could be due to the company field being a reference field. The script is looking at company and co attributes in AD then determining the SN company based on those attributes. Any thoughts?

 

(function transformEntry(source) {
    gs.log('Company Script started');
    var xformedComp = '';
    var adCompany = source.u_company;
    var countryCode = source.u_co;

    gs.log('Company: ' + adCompany);
    gs.log('Country Code: ' + countryCode);

    if (adCompany === 'Company 1') {
        xformedComp = 'Company 1';
    } else if (adCompany === 'Company 2' && countryCode === 'Country 1') {
        xformedComp = 'Company 3';
    } else if (adCompany === 'Company 2' && countryCode === 'Country 2') {
        xformedComp = 'Company 4';
    } else if (adCompany === 'Company 5' || (adCompany === 'Company 2' && countryCode === 'Country 3')) {
        xformedComp = 'Company 5';
    } else {
        xformedComp = 'Company 6'; // default response to catch edge cases
    }
    gs.log('xformed company is: ' + xformedComp);
    return xformedComp;
})(source);
1 REPLY 1

brianlan25
Kilo Patron

Looks like your missing answer = in line one. See example below.

answer = (function transformEntry(source) {

	// init integration util
	var integrationUtil = new HMIntegrationUtil();
	
	var sizeBytes = null;
	
	if(!gs.nil(source.u_sizegb))
		sizeBytes = integrationUtil.convertDiskGBToBytes(source.u_sizegb);
	
	return sizeBytes;

})(source);