Skip to Content
0

Adding an external supplier contact using the reassign directory in a script

Mar 17, 2017 at 07:51 PM

27

avatar image

Hi all, I am working on a web service to create a supplier contact. The script seems to be working fine to get the supplier and add the contact but I am having problems when I try to use the "Reassign to Directory Account" in the Account Management Tab under contacts. I am setting the dirEntry value which would seem to be the way to set the reassign but I am getting the error: "This field is required and must have a valid value" which suggests that it is not setting anything in the account management tab.

My script:

common.validateParams(params, getRequiredParams());

String externalId = (String)params.get(PARAM_ID);
vendor = common.findForEditByExternalId(externalId);


log.setLogMessage("vendor found" + vendor);
Logger.error(log);

if (vendor == null) {
ApplicationException ae = new ApplicationException(session, "exception.contactservice.no_vendordoc_found");
ae.setMessageModifiers(new Object[] { vendor });
throw ae;
}

ContactIBeanHomeIfc contactHome = (ContactIBeanHomeIfc) IBeanHomeLocator.lookup(session, ContactIBeanHomeIfc.sHOME_NAME);

log.setLogMessage("contacts" + contactHome.findByName(data.getName()));
Logger.error(log);

AssociativeCollectionIfc contactColl = vendor.getCollnContact();


ContactIBeanIfc contact = (ContactIBeanIfc) contactColl.create();


if (data.isSetFirstName()) {
contact.setFirstName(data.getFirstName());
}

log.setLogMessage("Set Last Name");
Logger.error(log);

if (data.isSetLastName()) {
contact.setLastName(data.getLastName());
}

log.setLogMessage("Set Email");
Logger.error(log);

if (data.isSetEmail()) {
contact.setEmail(data.getEmail());
}

log.setLogMessage("Set Name");
Logger.error(log);

if (data.isSetName()) {
contact.setName(data.getName());
}

log.setLogMessage("Set Currency");
Logger.error(log);

contact.setCurrency(vendor.getCurrencyObjRef());


log.setLogMessage("Set Language");
Logger.error(log);


contact.setDisplayLanguage(vendor.getDisplayLanguage());

log.setLogMessage("Supplier Contact Data After-" + contact.getName());
Logger.error(log);

log.setLogMessage("Supplier Contact Data-" + contact.getEmail());
Logger.error(log);

log.setLogMessage("Populated contact" + contact);
Logger.error(log);




vendor.getCollnContact().add(contact);

log.setLogMessage("Contact Added-" + vendor.getCollnContact());
Logger.error(log);


// create your new user bean




//Add code for abs account - this is all test stuff

//create account home
AbsAccountHomeIfc absHome = (AbsAccountHomeIfc)HomeLocator.lookup(session, "upp.user_account");

log.setLogMessage("Created abs account home");
Logger.error(log);





AbsAccount acct = (AbsAccount) absHome.create();


log.setLogMessage("Created abs acct");
Logger.error(log);


DirectoryObjectReference dirEntry = acct.getDirectoryEntry();
dirEntry.setUserId(contact.getName());
dirEntry.setDirectoryId(contact.getDirectoryConfiguration().getDisplayName());
log.setLogMessage("Directory Id" + dirEntry.getDirectoryId());
Logger.error(log);
log.setLogMessage("Display class" + dirEntry.getClassId());
Logger.error(log);
log.setLogMessage("Display user" + dirEntry.getUserId());
Logger.error(log);
log.setLogMessage("Display class" + dirEntry.getClass());
Logger.error(log);


vendor.setBuyerContactObjRef(acct.getAccountObjectReference());

log.setLogMessage("Set buyr contact reference");
Logger.error(log);





/* acct.getAclId().setDisplayName(contact.getName());*/
acct.setExternalId(data.getName());
acct.setName(data.getName());
log.setLogMessage("set name 1" + acct.getName());
Logger.error(log);
acct.setDisplayName(data.getName());
log.setLogMessage("set display name 1" + acct.getDisplayName());
Logger.error(log);

log.setLogMessage("set dir cred before" + acct.getDirectoryCredentials());
Logger.error(log);
acct.setDirectoryCredentials(data.getName());
log.setLogMessage("set dir cred" + acct.getDirectoryCredentials());
Logger.error(log);

log.setLogMessage("set dir princ before" + acct.getDirectoryPrincipal());
Logger.error(log);
acct.setDirectoryPrincipal(contact.getName());
log.setLogMessage("set dir princ" + acct.getDirectoryPrincipal());
Logger.error(log);

acct.setLoginId(data.getName());
acct.setFullDN(data.getName());
acct.setSynchWithLDAP(true);
acct.setUniqueDocName(data.getName());



acct.setDirectoryEntry(dirEntry);
log.setLogMessage("Created dirEntry" + dirEntry);
Logger.error(log);




//create account ifc

log.setLogMessage("account details before save" + acct);
Logger.error(log);



absHome.save(acct); //got an error here that the user was already created ************working
log.setLogMessage("saved abs account dir");
Logger.error(log);





common.getHome(ContactIBeanHomeIfc.sHOME_NAME).save(contact);
log.setLogMessage("saved contact");
Logger.error(log);


common.getHome(VendorIBeanHomeIfc.sHOME_NAME).save(vendor);


log.setLogMessage("Saved vendor");
Logger.error(log);

dxpjg.png (53.8 kB)
ouwka.png (85.0 kB)
thyq0.png (30.7 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers