on 09-04-2012 1:32 AM
Hi All,
I know there's been a lot of questions about creating a BO instance, so I thought I would provide you with an example from one of my projects. Some code is omitted to protect my Customer.
In this script I am checking if a Customer already exists matching my custom User BO. If not, I create an instance of the the Customer BO filled with elements from my custom BO. Anyway, I hope this helps.
// Get customers in User BO
query_customer = Customer.QueryByIdentification;
query_customer_selparam = query_customer.CreateSelectionParams();
query_customer_selparam.Add(query_customer.InternalID , "I", "EQ", this.UserID);
query_customer_result = query_customer.Execute(query_customer_selparam);
// If Customer does not exist, create Customer
if (query_customer_result.Count() == 0) {
var customerRoot : elementsof Customer;
customerRoot.CategoryCode = "2"; // or 1 or 3
customerRoot.InternalID = this.UserID;
CustomerBO = Customer.Create(customerRoot);
//Customer Indicator
CustomerBO.CurrentBusinessCharacters.CustomerIndicator = true;
CustomerBO.CurrentBusinessCharacters.ProspectIndicator = false;
//Organisation
CustomerBO.CurrentCommon.Organisation.Name.FirstLineName = this.UserName.content; CustomerBO.CurrentCommon.Organisation.Name.SecondLineName = "";
CustomerBO.Activate();
}
Hi Judson,
I am using the On Demand System 1302.
And I am able to create Customer Instances : InternalID, CategoryCode, CustomerIndicator, ProspectIndicator, from My BO this is possible.
But if i want to create some instances for the Address like: CityName, CountryCode, HouseID and other fields from address, I canot do this because those elements or others elements from Adress has NO Public Write Acces.
How can i create instances in the Customer BO for the Address elements from MY BO ?
Thanks,
Madalin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Great post Judson.. But I'm having an issue, In order to that script to work, its event handler must have activated the checkbox "SaveAfterExecution" or "SaveBeforeExecution".
But, those options create an empty record, how do i create an instance, without using those checkboxes?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Judson,
please post these things as blog post or document but not as a question. It's confusing.
Other than that: Keep on going, man!
I even have a use case for a simple add-on like this:
Create a custom BO for a supplier-request. Lots of companies - especially in the US - let their employees request new suppliers including all the necessary information such as 1099, minority-owned, women-owned, etc.
Add a simple approval workflow with the responsible buyer and there you go.
In addition you could add a website that your employees just send the new supplier a link to for them to fill out this information on their own.
Cheers, Christian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.