I have created a workflow to Convert a Lead into a Partner or into a Contact with two buttons. WORKFLOW: Lead Conversion
At the moment I'm completing the conversion to Partner. To create the new Partner record I needed to use a Custom Action (with SuiteScript 2.x). This was required to be able to grab the Address subsists since sublist are not accessible via workflow with a Create (or Goto) Record action. The script simply copy the Lead into a new Partner Record with all the addresses properly set in the Address sublist. CUSTOM ACTION: Create Partner With Address
Everything works perfectly but now I need to access the the newly created record with a Go to Record Action that need to position to that record for further developments.
I have created a the following fields on both the script and the workflow. Script fields: Partner ID custscript_mht_partner_id (Type: List/Record - Partner) custscript_mht_is_partner (Type: Checkbox)
Workflow fields: RecID (workflow) custworkflow_mht_record_id (Type: List/record - Partner) custworkflow_mht_is_partner (Type: CheckBox)
I need a way to set the workflow fields in the script, in particular i need to set custworkflow_mht_record_id to the newly created record ID so that I can use it (RecID (workflow)) in the Go To Record Action under the Record ID section in the Field dropdown.
So basically my question is: how to set workflow fields in a Custom Action SuiteScrip2.0
I can easily pre-set the script parameters in the workflow (under the Parameters section of the Custom Action) and access them in the script using the following instruction:
var scriptParam_is_partner = runtime.getCurrentScript().getParameter ({ name: 'custscript_mht_return_value' });
But I do I do the opposite for workflow fields?
--- Edited on 12/26/22 ---
NOTE: I have found a similar solution suggesting to used the return value of the script function directly to the RecID (workflow)in the "STORE RESULT IN" of the Parameter section of the Custom Action but unfortunately RecID is not available in the scroll down menu. It looks like only integer fields are available and not record type.
NOTE: The script function can return a value. This is limited to just one value . The value type is specified in the scrip under Parameters. By doing this I could at least return the new record Id to be used for the Go To record Action to position to the newly created record.
Also I have found this on SuiteAnswer 79755. This should be the solution with SuiteScrip 1. How do I set the WorkFlow custom field with SuiteScript 2.0.
_______________________
Set Value to a Custom Field via Workflow Action Script
Answer ID 79755
Scenario
Set value to a field on before record submit.
Solution
1. Create and upload the following script:
function workflowAction() {
nlapiLogExecution('DEBUG', 'test', 'start');
nlapiSetFieldValue('custworkflow10', 'Test Value');
}
2. On the workflow, create a workflow field. In the script above, 'custworkflow10' is the workflow field's ID.
3. On State 1, create new Action. Set it as the workflow Action Script and have the trigger as Entry. No need to set Store Result In.
4. Create a new state.
5. On State 2, create new Action, set it as the Set Field Value. On the Condition, set it to Visual Builder, then Set Field as the custom field. Set Compare Type to Contains and set Value Field to the workflow field.
6. Connect Sate 1 and State 2. Set Transition On Before Record Submit.