NVelocity template error in c# - asp.net

I am fairly new in using NVelocity. I am trying to edit some of the old templates for my company and i ma getting this error which i dont understand. OK so in template, if order has multiple shipments then show multiple shipment name and if only one then show only one shipment name. when there is multiple shipments, it works fine BUT when there is only one then somehow template does not renders the required shiment name instead printout the class name.
#if($order.Shipments.Count > 1)
#foreach($shipment in $order.Shipments)
#beforeall
#each
$shipment.ShipMethodName <strong>|</strong>
#else
$order.Shipments[0].ShipMethodName // in emails it renders "Orders.OrderShipmentCollection[0].ShipMethodName"
#end
#end
Please help.

I know this is an old question, but in case someone is looking for a solution later I thought I'd post an answer as I was going through old questions that don't have accepted answers. I don't how I didn't notice the error when I posted that comment in September last year.
$order.Shipments[0].ShipMethodName is giving you Orders.OrderShipmentCollection[0].ShipMethodName because NVelocity doesn't support indexers like C#, you need to use the get_Item() method, i.e. $order.Shipments.get_Item(0).ShipMethodName that is the underlying method the C# compiler creates for indexers.
What is happening is $order.Shipments prints out the type name (Orders.OrderShipmentCollection) and the rest [0].ShipMethodName just gets printed verbatim.

Related

Wordpress + Contact Form 7: One or more fields have an error (treating first field as empty even when it is filled)

I am asking this question after I found the answer so that no one else spends much time debugging it in case the same happened to them (my googling didn't yield many useful results)
In short, some of my CF7 forms suddenly stopped submitting and it was giving me the orange error about empty fields. It was also flagging the first field in the form as being empty even though it was filled.
Nothing was being logged in Flamingo. Recaptcha was working properly. I attempted to fix the permalinks. Nothing was fixing the issue.
Turns out it was a problem with how some field codes were written inside the HTML of the form. The type of error will be unique, but in general, make sure your fields are written properly and that there are no commented parts in the form HTML.
In my case, the error was as follows:
I was using the following code for some select fields:
And to be written properly they had to be as such:
That was it for me.

Setting Vendor Number in X++ General Journal

I'm posting to a general journal in ax 2012. I'm able to create the journal and enter most line information from x++ code. Now i'm having an issue with some vendor numbers.
When I use this code most of the time it works. But there are a few vendor numbers that are not able to be found from this table and of course throws an error. Weird thing is if I actually go into ax and type in the vendor number it does accept it because it has been setup in the system but by this code it is not working (for some).
Just wondering if there is something wrong with how the vendor number is setup, properly not linked with something, or if there is another way to properly set this parameter.
It looks like parmledgerDimension uses a RecId for vendors and only pulls it from DimensionAttributeValueCombination.
Any ideas?
DimensionAttributeValueCombination davc;
firstonly RecId from davc where davc.DisplayValue == account; //could be 010-000001
journalTrans.parmLedgerDimension(davc.RecId);
Try using
DimensionStorage::getDynamicAccount(account, LedgerJournalACType::Vend);
https://msdn.microsoft.com/en-us/library/dimensionstorage.getdynamicaccount.aspx
Edit: the first line I posted was to get the default dimension. I'll leave it in case you need it
LedgerJournalEngine::getAccountDefaultDimension(account, curext(), LedgerJournalACType::Vend);
https://msdn.microsoft.com/en-us/library/ledgerjournalengine.getaccountdefaultdimension.aspx

Open direct links to AX-objects or datasets from external application

Is there a way to open a specified document, eg "production order 123" or form, eg "purchase orders" in Ax2012 from an external application directly?
In detail, I'm looking for something similiar like AXPath, but this doesn't work with versions greater then 2009.
Is there any ( maybe included ) way to achieve this?
There is! It's using AX's drilldown functionality which uses AxHLink.exe to handle dynamics:// URLs, which are passed to the Classes\SysStartupCmd function. You could also create some custom code there if you wanted to launch the AX client executable directly.
My question I asked some while back should have a great deal of useful information in it here:
What handles dynamics:// URLs?
Some more can be found: http://technet.microsoft.com/en-us/library/aa834337.aspx
EDIT:
It sounds like you are confused or the posts weren't clear enough. I think you have 3 basic options.
Dynamics:// URLs are handled by AxHLink.exe and they only seem to handle drilldown, viewalert, and viewalertrule. So if you want to use Dynamics:// URLs, you will need to hi-jack those somehow. There is a pastbin from Jan in that other stack post.
Create a custom URI handler and event poller (lot of work) see http://axcoder.blogspot.dk/2010/10/how-to-open-form-in-running-ax-from.html
Extend SysStartupCmd and then instead of using Dynamics:// URLs, just call Ax32.exe -startupCmd directly and a parameter can be passed to your custom class.

Invalid field/related field combination

I'm trying to make an entity like vendor in ax 2012. When I click the "new" button I get following error;
Invalid field/related field combination.
I have looked for it on search engines and found out that it might be due to wrong joins used in data sources of the form. I have gone through the joins and links, they all are fine but I'm still getting the same error.
Any one, any idea?
Put a breakpoint in the info.add method to catch AX in the deed.

Webform submission: how to send the translation of a variable by mail

In a Drupal project, i have a basic weborm. As soon as the user submits one, an email is send with all the things he just wrote.
Example:
Imp_First_Name:%value[firstname]
Imp_Last_Name:%value[lastname]
Imp_City:%value[lastname]
Imp_Country:%value[country]
Imp_Email:%value[email]
Imp_Subject:%value[subject]
I have a problem on this line:
Imp_Subject:%value[subject]
Subject contains what the user have selected within a select list. My problem is when the website is set to chinese, all is written in chinese obviously but i don't want the chinese version to be sent. I need the english one.
For example :
In my webform, the user has the choice between 3 countries:
Afghanistan|阿富汗
Afrique du Sud|南非
Albanie|阿尔巴尼亚
I need the country name in latin alphabet ! How can i manage to do this?
thanks in advance for your help
It's a tricky one...
There is substitution and also two possible template layers. One comes from webform and second comes from mailsystem / mail handler module.
I'm assuming that the substitution is done before the template layer so the t() function should be applied either within a hook on that level or within the proper template file.
Debugging with XDebug would really help to solve the issue.

Resources