Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using the standard 'create invoice from salesorder' in workflows
(08-07-2016, 03:33 PM)joebordes Wrote: The missing ampersand has nothing to do with the problem. The correct way to define the task is WITH the ampersand.

When you extend a class

PHP Code:
class CBTagTask extends VTTask

you inherit all of it's methods, but if that class has defined any method as "abstract" your new class MUST implement those and they must follow the exact same profile as defined in the base class.

You can see here

that the doTask() method gets the entity by reference so your class, which constructs upon that one has to define that method like that.

Thanks, I've seen abstract class definitions but never quite knew what they were. I know about interfaces (never implemented them but they're in the book I'm reading) but never knew abstract classes had similar behaviour. Anyway, the thing I am curious about is why your example does not have to implement the argument as a reference here.

(08-07-2016, 03:55 PM)joebordes Wrote: Why did you change the name here:

PHP Code:
$data['LineItems'] = $wsso['pdoInformation']; 

shouldn't it be

PHP Code:
$data['pdoInformation'] = $wsso['pdoInformation']; 


I've used this code to start:

PHP Code:
include_once 'include/Webservices/Revise.php';

try {
       $user = new Users();
       $current_user $user->retrieveCurrentUserInfoFromFile(Users::getActiveAdminId());
$wsid vtws_getWebserviceEntityId('Invoice''CRMID'); // CRMID => Is the Existing Record ID in the CRM.
       $data = array (
              'subject' => 'Mangoes Goes Revised',
              'sostatus' => 'Created',
              'invoicestatus' => 'Created',
              'hdnTaxType' => 'group',
              'conversion_rate' => 1,
              'bill_street'=>'Mango Street',
              'id'=> $wsid,
      $invoice vtws_revise($data$current_user);


} catch (
WebServiceException $ex) {

from here. There the array label is 'LineItems', so I assumed this was the correct label for invoice creation. Also, this worked when I tested using a separate test file.

(08-07-2016, 03:48 PM)joebordes Wrote: Next up is the default value for the due date. You should not need to setup the workflow task to get the duedate offset. This is better done using (Field) Mapping Business Mapping

This type of business mapping serves to define field values to capture when converting from one module to another, but it also serves to set default values when creating a new record. You can achieve this by creating a mapping with the same module name for both sides, for example, in this case Invoice2Invoice. Just to test it I created the mapping below and now when I create a new invoice my due date is set to 30 days from today.

          <OrgfieldName>add_days(get_date('today'), 30)</OrgfieldName>

we must get the workflow task to use this mapping because with that you can define ANY field as you like without having to modify the workflow and it will also serve for normal user creation.

give that a try just to get a hang of how incredibly powerful the mappings are and how much you can really customize coreBOS now without touching to much code.

I continue....

Thanks, I'll give that a try. But one question: would it be possible to create one workflow that sets the date of the invoice 30 days from now and create another that sets the date 60 days? So we can check certain conditions and base the invoice duedate on that? I certainly see the power of the business maps, but would it be an idea to create a dropdown in the workflow config where you can select a business map to execute or does my limited knowledge of the module make me think in the wrong direction here?

About the label 'pdoInformation' to 'LineItems': even if this was wrong, the workflow still should've worked. I transfer the complete $wsso array into $data first, thereby creating a label called 'pdoInformation' in the $data array. I create the LineItems label as a copy since I thought this is what the system wanted on invoice creation through webservice. Although this worked in a separate testfile, it does not when you use it in a workflow. I wish there was a better way of debugging workflows, so I could see what's going on..

(08-07-2016, 04:33 PM)joebordes Wrote: Ok, I had a look. This is what you have to do

basically repeat that logic. It will be something in this line:

PHP Code:
$focus CRMEntity::getInstance('Invoice');

$so_wsid,$soid) = explode('x',$entity->getId());
$so_focus CRMEntity::getInstance('SalesOrder');
$so_focus->id $soid;
$focus getConvertSoToInvoice($focus$so_focus$soid);  // this will do the Mapping for the duedate and others SalesOrder2Invoice

 // we do this to get the pdoInformation array
$wsso vtws_retrieve($entity->getId(), $current_user);
$focus->column_fields['pdoInformation'] = $wsso['pdoInformation'];

$invoice vtws_create('Invoice'$focus->column_fields$current_user); 

that should be all you need.

Please BE CAREFUL I have NOT tested the code above

I will test this and let you know.

Messages In This Thread
RE: Using the standard 'create invoice from salesorder' in workflows - Guido1982 - 08-08-2016, 08:47 AM

Forum Jump:

Users browsing this thread: 1 Guest(s)