Alfresco workflow api is loosing a variable - workflow

I have an Alfresco community 5.2 installation with a custom workflow. The users needs to specify some actors to be part of this workflow and review the submitted document. The users are divided in 4 groups (co-authors, reviewers, approvers, authorizer) and I start the workflow using Alfresco JS Api passing all variables and actors.
The problem that I have is: a workflow variable of one of those actors group, the reviewers, is correctly passed to wf Params but is received as null when the workflow is started
var wfparams = new Array();
wfparams["mywf:coAuthorsAssignees"] = coAuthorsProp;
wfparams["mywf:reviewersAssignees"] = reviewersProp;
wfparams["mywf:approverAssignee"] = approverProp;
wfparams["mywf:authorizerAssignee"] = authorizerProp;
wfparams["bpm:priority"] = workflowPriorityProp;
wfparams["mywf:taskDueDateDaysNumber"] = workflowTaskDueDateDaysNumberProp;
wfparams["bpm:description"] = workflowMessageProp;
wfparams["bpm:workflowDescription"] = workflowMessageProp;
wfparams["mywf:copyToInitiator"] = copyToInitiator;
wfparams["mywf:previousTaskComments"] = workflowInitiatorComment;
wfparams["_startTaskCompleted"] = new Date();
logger.info("mywf:reviewersAssignees"); // OK, the variable is correct
workflowAction.startWorkflow(package, wfparams);
And here is my start
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://alfresco.org">
<process id="DTTPublishWorkflow" name="Parallel Review And Approve Document" isExecutable="true">
<extensionElements>
<activiti:executionListener event="start" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
<activiti:field name="script">
<activiti:string><![CDATA[//checkSingleWFIstance();
// printing the variable inside the workflow (bpmn), I see it null
logger.info(execution.getVariable('mywf_reviewersAssignees')) // null
<!-- ... -->
How it is possible? What am I missing?
Or what can I do to figure out what the problem is? Can I debug somehow that happens under startWorkflow(package, wfparams);
-- EDIT --
Could it be some strange problem in javascript object conversion ?

Look like some prefix mistake.
You are assigning by prefix "mywf" and you are fetching by "eneawf".
Is this your way of fetching or mistake?

Related

How to Create and Associate a Category to a Contact using EWS Managed API 2.2

Is it possible to create a Category Item Object and Associate it with a Contact using the EWS Managed API?
You can assign a Category to any Object in a Mailbox using the Categories property https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.item.categories(v=exchg.80).aspx .
For a particular color/description to be show in Outlook or OWA the category you pass in must match an Item in the Master category list. You can read/modify the Master category list in a Mailbox using EWS eg https://social.msdn.microsoft.com/Forums/en-US/e5c5f072-0b5c-49ce-9db7-57f76f5e011e/edit-master-category-list-in-exchange-2010-via-ews?forum=exchangesvrdevelopment and https://social.msdn.microsoft.com/Forums/en-US/a3917500-2bbc-4def-98b4-696e49efed6f/adding-categories-to-a-users-master-category-list-in-exchange-2010-using-ews?forum=exchangesvrdevelopment
I came across this post while looking to update the master category list using EWS, but not the Managed API. In case anyone else is looking to do the same thing, here's the solution I came up with, which uses Python and requests:
import base64
import requests
from requests_ntlm import HttpNtlmAuth
# Create the XML request template for EWS
payload = r"""<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013" />
</soap:Header>
<soap:Body>
<m:UpdateUserConfiguration>
<t:UserConfigurationName Name="CategoryList">
<t:DistinguishedFolderId Id="calendar">
<t:Mailbox>
<t:EmailAddress>your_email#your_domain.com</t:EmailAddress>
<t:RoutingType>SMTP</t:RoutingType>
<t:MailboxType>Mailbox</t:MailboxType>
</t:Mailbox>
</t:DistinguishedFolderId>
</t:UserConfigurationName>
<t:XmlData>{}</t:XmlData>
</m:UpdateUserConfiguration>
</soap:Body>
</soap:Envelope>"""
# Create the categories XML
# Colors: https://learn.microsoft.com/en-us/openspecs/exchange_server_protocols/ms-oxocfg/eb7cac90-6200-4ac3-8f3c-6c808c681c8b
xml_data = r"""<?xml version="1.0"?>
<categories default="First category" xmlns="CategoryList.xsd">
<category name="First category" color="1" />
<category name="Second category" color="2" />
</categories>"""
# Encode the payload and insert it into the XML request
xml = base64.b64encode(xml_data.encode())
payload = payload.replace('{}', str(xml).strip('b\''))
# Use requests with the NTLM authentication libary to submit the request
headers = {'content-type': 'text/xml'}
ews_url = 'https://mail.your-organizations-exchange-server.com/EWS/Exchange.asmx'
session = requests.Session()
session.auth = HttpNtlmAuth(exhange_username, exchange_password)
response = session.post(ews_url, data=payload, headers=headers)
print(response.text)

Magento: Send a mail directly to my supplier when payment is set to be received

I'd like to send an automatic email to my supplier, when the order is checked as payed. I've a external supplier that start to produce when i tell him, so when the payment is received, I can confirm to him the production. I'd like to automate this process and I like to use a similar confirmation order email, but adding a custom attribute instead of the sku.
Thank you!
--- EDIT ---
I'm reached my goal inserting those lines, but I've still some problem in the Observer line 24 at $result line, there's an error for one ",".
config.xml
<?xml version="1.0"?>
<config>
<modules>
<Electricjesus_Notifyowner>
<version>0.1.0</version>
</Electricjesus_Notifyowner>
</modules>
<global>
<models>
<notifyowner>
<class>Electricjesus_Notifyowner_Model</class>
</notifyowner>
</models>
<events>
<sales_order_payment_pay>
<observers>
<notifyOwnerEvent>
<class>notifyowner/observer</class>
<method>notifyOwnerEvent</method>
</notifyOwnerEvent>
</observers>
</sales_order_payment_pay >
</events>
</global>
Electricjesus_Notifyowner.xml
<?xml version="1.0"?>
<config>
<modules>
<Electricjesus_Notifyowner>
<active>true</active>
<codePool>local</codePool>
</Electricjesus_Notifyowner >
</modules>
and Observer.php with the error
// parameters you can get from the $observer parameter:
// array(’payment’ ? $this, ‘invoice’ ? $invoice)
$payment = $observer->getPayment();
$invoice = $observer->getInvoice();
// derivative data
$order = $invoice->getOrder(); // Mage_Sales_Model_Order
$ownerEmail = 'test#gmail.com';
$emailTemplate = Mage::getModel('core/email_template')
->loadDefault('order_new');
$emailTemplate
->setSenderName(Mage::getStoreConfig('trans_email/ident_support/name'))
->setSenderEmail(Mage::getStoreConfig('trans_email/ident_support/email'))
->setTemplateSubject('Prova di Ordine Confermato dopo pagamento');
$result = $emailTemplate->send(Mage::getStoreConfig('trans_email/ident_general/email'),(Mage::getStoreConfig('trans_email/ident_general/name'), $observer->getCustomer()->getData());
/*
- build data
- build email structure
- send email via any php mailer method you want
*/
return $this; // always return $this.
}
}
Can you pls help me to undestand why the error for a comma? Thank you!
There in magento has two dispatch event
1.sales_order_payment_place_end
2. sales_order_payment_place_start.
As per your Please follow my below code. add observer
<global>
<events>
<sales_order_payment_place_end>
<observers>
<mymodule>
<type>singleton</type>
<class>mymodule/observer</class>
<method>handleOrder</method>
</mymodule>
</observers>
</sales_order_payment_place_end>
</events>
</global>
Then create observer.php under model directory
class Mycompany_Mymodule_Model_Observer
{
public function handlePayment($observer)
{
$order = $observer->getOrder();
$payment=$order->getPayment();
/// put logic as per your requirement.
}
}
I did not get time to test this code but i am sure logic is same like this. Thanks.

how to delete a scenario in atg through API methods

I have created a scenario by creating a myScenario.sdl in my local config folder /atg/registry/data/scenarios/myScenario.sdl
myScenario.sdl
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE process SYSTEM "dynamosystemresource:/atg/dtds/pdl/pdl_1.0.dtd">
<process author="admin" creation-time="1413804041263" enabled="false" last-modified-by="admin" modification-time="1413804191188">
<segment migrate-subjects="true">
<segment-name>ItemAddedToOrder</segment-name>
<!--================================-->
<!--== Item added to order Quantity with fraction is defined -->
<!--================================-->
<event id="1">
<event-name>atg.commerce.order.ItemAddedToOrder</event-name>
<filter construct="event-property-filter" operator="isNotNull">
<event-property construct="event-property">
<property-name>quantityWithFraction</property-name>
</event-property>
</filter>
</event>
<!--================================-->
<!--== Log a message message: Quantity With Fraction is Defines logTriggeringEvent: true -->
<!--================================-->
<action id="2">
<action-name>Log a message</action-name>
<action-param name="message">
<constant>Quantity With Fraction is Defines</constant>
</action-param>
<action-param name="logTriggeringEvent">
<constant type="java.lang.Boolean">true</constant>
</action-param>
</action>
</segment>
</process>
And enabled the scenario:
Registry scenarioRegistry = scenarioManager.getScenarioRegistry();
byte[] data = (byte[]) scenarioRegistry.getItem(pScenarioPath);
String xml = null;
if (data != null) {
xml = new String(data, "UTF-8");
} else {
Assert.fail("No scenario is existed to enable/disable");
}
String updatedXml;
if (scenarioState && xml != null) {
updatedXml = xml.replaceAll("enabled=\"false\"", "enabled=\"true\"");
} else {
updatedXml = xml.replaceAll("enabled=\"true\"", "enabled=\"false\"");
}
scenarioRegistry.putItem(pScenarioPath, updatedXml.getBytes("UTF-8"));
Now with this above written code, I can both disable or enable the scenario by changing the state as false and true respectively. But I want to delete the scenario(please remember, my requirement is DELETE not DISABLE SCENARIO). I know using scenarioManager.updateScenario() deleted the scenario. Is my understanding right?
One more thing, I know I can delete the scenario directly from ACC. But I need to code via code not manually from ACC.
Please share your thoughts!
Did you try scenarioRegistry.removeItem(path);

Magento getEvent()->getOrder empty

I'm trying to get an Observer working to see if a payment has been made via check/cheque, I know the Observer is being used as I have a log record to show. However when I try to access the Order it is either empty or will not print to the log file.
app/etc/modules/Foo_Bar.xml
<?xml version="1.0"?>
<config>
<modules>
<Foo_Bar>
<active>true</active>
<codePool>local</codePool>
</Foo_Bar>
</modules>
</config>
app/code/local/Foo/Bar/etc/config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<config>
<global>
<models>
<foo_bar>
<class>Foo_Bar_Model</class>
</foo_bar>
</models>
<events>
<sales_order_payment_place_end> <!-- event -->
<observers>
<foo_bar> <!-- unique for event -->
<!-- type: singleton | disable | model -->
<class>foo_bar/observer</class>
<method>SalesOrderPaymentPlaceEnd</method>
</foo_bar>
</observers>
</sales_order_payment_place_end>
</events>
</global>
</config>
app/code/local/Foo/Bar/Model/Observer.php
<?php
class Foo_Bar_Model_Observer
{
public function SalesOrderPaymentPlaceEnd(Varien_Event_Observer $observer)
{
Mage::log('Location: SalesOrderPaymentPlaceEnd');
$order = $observer->getEvent()->getOrder();
Mage::log('order: '.$order);
}
}
The first log works as expected, however I'm sure getOrder() isn't working as my second log entry just prints 'order: '.
Thanks
#James has already commented this..I am explaning
The event "sales_order_payment_place_end" located in "app\code\core\Mage\Sales\Model\Order\Payment.php" .
The event have only one parameter that is Payment. So
$order = $observer->getEvent()->getOrder();
will not work. You need to use
$orderPayment = $observer->getEvent()->getPayment();
What worked for me was below:
public function autoInvoiceForOfflinePayment(Varien_Event_Observer $observer)
{
$order = $observer->getEvent()->getPayment()->getOrder();
// In my case I was trying to get the payment method code, e.g.
$order->getPayment()->getMethodInstance()->getCode()
}
I hope this helps (Magento EE 1.14.2)
What I discovered, which I forget and often discover again when creating a hook is to look at the line in the file dispatching the event:
e.g. "app\code\core\Mage\Sales\Model\Order\Payment.php"
Mage::dispatchEvent('sales_order_payment_place_end', array('payment' => $this));
So you want to get the event first, then in the array the payment variable:
$order = $observer->getEvent()->getPayment();
From there you can get any public functions in that file, the same principle seems to apply throughout.

Customer attributes not saving on Add

So I've been experimenting with adding customers to QuickBooks Online from a local database instance at our business. I want to keep track of our internal customer reference numbers in QBO, so have tried to save those to several different attributes like AcctNum, ExternalKey, ExternalId, AlternateId, or even directly to the Id attribute. After attempting to save to these fields, the return result looks good.
var qbCustomer = new Customer
{
AcctNum = customer.CustRef.ToString(CultureInfo.InvariantCulture),
ExternalKey = new IdType {idDomain = idDomainEnum.NG, Value = customer.CustRef.ToString(CultureInfo.InvariantCulture)},
Id = new IdType {idDomain = idDomainEnum.NG, Value = customer.CustRef.ToString(CultureInfo.InvariantCulture)},
Name = customer.CustName1,
FamilyName = customer.CustRef.ToString(CultureInfo.InvariantCulture),
};
Customer resultCustomer = dataServices.Add(qbCustomer);
But the next time I retrieve those customers, all of those fields are just null. Why are these fields not saving? Is there another more appropriate field to use to store an external ID besides just using one of the plain text fields (Name, Address, etc.)?
UPDATE:
Here's the raw XML exchange.
What I sent when adding a new customer:
<?xml version="1.0" encoding="utf-8"?>
<q1:Customer xmlns="http://www.intuit.com/sb/cdm/qbo" xmlns:q1="http://www.intuit.com/sb/cdm/v2">
<q1:Id>7</q1:Id>
<q1:ExternalKey>7</q1:ExternalKey>
<q1:TypeOf>Person</q1:TypeOf>
<q1:Name>Customer Name</q1:Name>
<q1:FamilyName>7</q1:FamilyName>
<q1:AcctNum>7</q1:AcctNum>
</q1:Customer>
Intuit's response:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Customer xmlns="http://www.intuit.com/sb/cdm/v2" xmlns:qbp="http://www.intuit.com/sb/cdm/qbopayroll/v1" xmlns:qbo="http://www.intuit.com/sb/cdm/qbo">
<Id idDomain="QBO">12</Id>
<SyncToken>0</SyncToken>
<MetaData><CreateTime>2013-07-25T13:51:43-07:00</CreateTime><LastUpdatedTime>2013-07-25T13:51:43-07:00</LastUpdatedTime></MetaData>
<Name>Customer Name</Name>
<WebSite/>
<Email/>
<FamilyName>7</FamilyName>
<CustomField xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="StringTypeCustomField"><DefinitionId>Preferred Delivery Method</DefinitionId><Value>DONT</Value></CustomField>
<CustomField xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="StringTypeCustomField"><DefinitionId>Resale Number</DefinitionId></CustomField>
<CustomField xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="BooleanTypeCustomField"><DefinitionId>Bill With Parent</DefinitionId><Value>false</Value></CustomField>
<ShowAs>Erik Kunze/Magdalena Guarda Munoz</ShowAs>
<OpenBalance><Amount>0</Amount></OpenBalance>
</Customer>
My retrieval later:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<qbo:SearchResults xmlns="http://www.intuit.com/sb/cdm/v2" xmlns:qbp="http://www.intuit.com/sb/cdm/qbopayroll/v1" xmlns:qbo="http://www.intuit.com/sb/cdm/qbo">
<qbo:CdmCollections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Customers">
<Customer>
<Id idDomain="QBO">12</Id>
<SyncToken>0</SyncToken>
<MetaData><CreateTime>2013-07-25T13:51:43-07:00</CreateTime><LastUpdatedTime>2013-07-25T13:51:43-07:00</LastUpdatedTime></MetaData>
<Name>Customer Name</Name>
<WebSite/>
<Email/>
<FamilyName>7</FamilyName>
<CustomField xsi:type="BooleanTypeCustomField"><DefinitionId>Bill With Parent</DefinitionId><Value>false</Value></CustomField>
<CustomField xsi:type="StringTypeCustomField"><DefinitionId>Preferred Delivery Method</DefinitionId><Value>DONT</Value></CustomField>
<ShowAs>Erik Kunze/Magdalena Guarda Munoz</ShowAs>
<OpenBalance><Amount>0</Amount></OpenBalance>
</Customer>
</qbo:CdmCollections>
<qbo:Count>1</qbo:Count>
<qbo:CurrentPage>1</qbo:CurrentPage>
</qbo:SearchResults>
There's no AcctNum in the raw XML anywhere.
You are referring QBD's customer endpoint in apiexplorer.
Correct QBO link - https://developer.intuit.com/apiexplorer?apiname=V2QBO#Customer
Api Docs & Sample Create request - https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v2/0400_quickbooks_online/customer#Sample_Create_Request_XML
Simplest request body to create QBO customer -
<Customer xmlns:ns2="http://www.intuit.com/sb/cdm/qbo" xmlns="http://www.intuit.com/sb/cdm/v2" xmlns:ns3="http://www.intuit.com/sb/cdm/baseexceptionmodel/xsd">
<TypeOf>Person</TypeOf>
<Name>TestQBCustomer12345</Name>
</Customer>
Simplest Response
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Customer xmlns="http://www.intuit.com/sb/cdm/v2" xmlns:qbp="http://www.intuit.com/sb/cdm/qbopayroll/v1" xmlns:qbo="http://www.intuit.com/sb/cdm/qbo">
<Id idDomain="QBO">14</Id>
<SyncToken>0</SyncToken>
<MetaData>
<CreateTime>2013-07-25T14:08:49-07:00</CreateTime>
<LastUpdatedTime>2013-07-25T14:08:49-07:00</LastUpdatedTime>
</MetaData>
<Name>TestQBCustomer12345</Name>
<WebSite/>
<Email/>
<CustomField xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="StringTypeCustomField">
<DefinitionId>Preferred Delivery Method</DefinitionId>
<Value>DONT</Value>
</CustomField>
<CustomField xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="StringTypeCustomField">
<DefinitionId>Resale Number</DefinitionId>
</CustomField>
<CustomField xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="BooleanTypeCustomField">
<DefinitionId>Bill With Parent</DefinitionId>
<Value>false</Value>
</CustomField>
<ShowAs>TestQBCustomer12345</ShowAs>
<OpenBalance>
<Amount>0</Amount>
</OpenBalance>
</Customer>
You can test it first using apiexplorer then use the proper setters to do the same in your code.
Please let me know how it goes.
Thanks
Refer to the documentation:
https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v2/0500_quickbooks_windows/0600_object_reference/customer
You'll note that:
Id is an internal key generated by IPP/IDS - it's NOT something you can set yourself.
ExternalKey is the same situation - it's generated by IPP/IDS, not set-able by you.
ExternalId is marked "UNSUPPORTED FIELD."
AlternateId is marked "NOT SUPPORTED."
The only one of these fields that should work is:
AcctNum
If you're still having problems with that field, the way to troubleshoot is to get the raw XML outgoing request from Intuit, the raw XML that you get back (showing success) and then the raw response that you get back when you query it, showing that it's NULL.