...
After retrieving the CRM Session, you can use it to get information about the logged in user, the server, the database and the general and formatting settings.
Code Block |
---|
title | Example 1 - Logged In User |
---|
collapse | true |
---|
|
public CRMDO copy(CRMDO dto)
{
CRMSession session = getCRMSession();
if( dto instanceof CUSTOMCRMDORentalTypeProduct)
{
CUSTOMCRMDORentalTypeProduct oldProduct = (CUSTOMCRMDORentalTypeProduct) dto;
CUSTOMCRMDORentalTypeProduct newProduct = (CUSTOMCRMDORentalTypeProduct)oldProduct.clone();
newProduct.setCreatedDate(getCurrentDate());
newProduct.setCreatedByUnit(session.getUnit());
newProduct.setCreatedByUser(ejbSession.getLoggedUser());
newProduct.setUpdatedByUnit(null);
newProduct.setUpdatedByUser(null);
newProduct.setUpdatedDate(null);
}
} |
...
Code Block |
---|
title | Example 3 - General Settings |
---|
collapse | true |
---|
|
protected CRMDOContactInformation setDefaultResidenceCountry(CRMDOContactInformation contact) throws Exception {
GeneralSetting generalSettings = getCRMSession().getGeneralSettings();
if (generalSettings!=null)
{
contact.setResidenceCountry(generalSettings.getDefaultCountry());
}
return contact;
} |
Code Block |
---|
title | Example 4 - Translation |
---|
collapse | true |
---|
|
public LookupBuilder getAllowedProductOptions(CUSTOMCRMDORentalType rentalType) throws Exception {
ArrayList<CRMDO> allowedProducts = rentalTypeProductBean.loadAllowedProducts(rentalType);
if(allowedProducts!=null)
{
Iterator<CRMDO> iter = allowedProducts.iterator();
while (iter.hasNext())
{
CUSTOMCRMDORentalTypeProduct rtProduct = (CUSTOMCRMDORentalTypeProduct)iter.next();
if(rtProduct!=null && rtProducT.getProduct()!=null)
{
String value = rtProducT.getProduct().getCode();
if(rtProducT.getProduct().getType()!=null)
{
value += "(" + getCRMSession().getTranslation(rtProducT.getProduct().getType().getName()) + ")";
}
builder.build(rtProducT.getProduct().getId(),value);
}
}
}
return builder;
} |