Projects/Create New In Selectors/Technical Documentation
http://wiki.openbravo.com/wiki/Projects/Create_New_In_Selectors/Technical_Documentation
'Create New' In Selectors - Technical Documentation
New implementations
The process in charge of adding the new record to the selector should be in charge of:
- Handle, in case that exists, the current written value in the selector input or in the selector filters in the popup:
- This written values are provided from the selector to the process in a JSON array called "enteredValues" that should be handled by the javascript "On Load Function" defined in the "Process Definition".
- The structure of each element of this JSON array is
{*input_name*: *value*}
- Do the creation of the new record in the instance that corresponds:
- This logic should be handled by the java "Handler" defined in the "Process Definition".
- This java should collect the values of the form of the process and add a new record to the corresponding table.
- Add and select the created record in the selector form item:
- This logic should be handled by the java "Handler" defined in the "Process Definition".
- This java should return an action with the following structure:
{ refreshParent: false responseActions: { setSelectorValueFromrecord: { record: { map: *theDisplayedFieldValue*, value: *theValueFieldValue* } } } }
- The 'refreshParent' false is to avoid the whole form be reloaded after the addition of one record to the selector. If this attribute is not set to 'false' can cause problems in grid editing view.
- The returned 'record' could have this simplified structure, that automatically will be handled by the system and draw and select the proper record in the selector, or could be a real full 'record'. With this simplification you can avoid to know while developing the process which is the name of the displayed field (typically is 'name') and the name of the value field (typically is 'id') and just focus in the value you want to be shown (map) and the value you want to store (value).
- Example of simplified record
record: { map: "Alimentos y Supermercados, S.A", value: "A6750F0D15334FB890C254369AC750A8" }
- Example of full record (of the standard 'Business Partner' selector)
record: { bpid: "A6750F0D15334FB890C254369AC750A8" category: "Customer - Tier 1" creditAvailable: 0 creditUsed: 0 customer: true name: "Alimentos y Supermercados, S.A" value: "ES-C1/0001" vendor: false }
Real example
Here there is a How to