Can anyone tell me which method to put a Query Range into for a class which is batchable?
I have a sample batch class, which runs fine. It retrieves all the records in the Sales Table. I know that I need to add a QueryBuildRange object somewhere, then set the value of the range to a particular value (e.g. Sales ID = 00123456), but I'm not sure what method to put it in (main? Run? QueryRun? InitQuery?)
Thanks for your help!
It depends on what you're wanting to do, but in AX 2009 for batch, you can look at InventCountCreate_Base for an example of how Microsoft does it.
Specifically these two methods:
\Classes\InventCountCreate_Base\new
\Classes\InventCountCreate_Base\initQueryRun
Microsoft does it several different ways. You can see an alternative method in WMSShipmentReservationBatch in these two methods:
\Classes\WMSShipmentReservationBatch\main
\Classes\WMSShipmentReservationBatch\buildQueryRun
Related
Is it possible to retrieve multiple values from XCOM, pushed by a single task but with different keys?
I think I've seen examples to this:
# pulls one value
pulled_value = ti.xcom_pull(key=None, task_ids='my_task_id')
and to this:
# pulls multiple values but from multiple tasks
pulled_value_1, pulled_value_2 = ti.xcom_pull(key=None, task_ids=['my_task_id_1', 'my_task_id_2'])
What I need is would possibly look like this:
# pulls multiple values but from a single
pulled_value_1, pulled_value_2 = ti.xcom_pull(key=['my_key_1', 'my_key_2'], task_ids='my_task_id')
I can't find this in the documentation.
Is this even possible?
If yes, it makes a single database query in the background, or just repeats a single query multiple times?
If not, how could I get similar behavior?
Answering your questions:
There is no such feature.
xcom_pull accepts task_ids: Optional[Union[str, Iterable[str]]] but with the same key. You can open a PR to Airflow for adding the functionality you seek.
As for number of queries: I assume that by "repeats a single query" you are asking if it execute a query per task_id. The answer is No. Airflow did this optimization in PR.
In the source code you can see that xcom_pull() uses Xcom.get_many() and get_many creates a filter using IN which allows to compare against multiple values. You can see the relevant code lines here.
I need to create simple query which will show all contracts which will expire in next 3 months. I know how to do that with SQL, but how to do that in Visual Studio when I create query. I added data source Contract table. Added range. Column where is date about expiring is VALIDTO.
So, something to write up in value, or how to do that ?
Solved with two ranges on VALIDTO column. Used (MonthRange(0,3)) with (Day(0)) formulas.
I want to synchronize data for actual work from a web-based application of my company with MS Project. I am currently developing an Add-In with JavaScript in order to achieve this:
The red circle in my screenshot shows the data that I want to set programmatically. However, I have no idea how to achieve this.
I understand that I can get Task GUIDs and then set task fields using the task GUID and the field ID. This way I can save the cumulative actual work, but not per day like in my screenshot.
The API Docs on the MS Office Website are rather hard to read and navigate. Any help would be apprechiated!
Let's first separate the language from the operation.
Operationally, based on your circle, you want to set work for a task to happen on individual days? This is done using timeScaleData, see https://learn.microsoft.com/en-us/previous-versions/office/developer/office-2003/aa206255(v=office.11) . When I did something similar (in VBA), I had to (1) get an array of time scale values, then (2) walk/iterate through that array and set work to those days:
set timeScaleValsArry = myTask.Assignments(1).TimeScaleData(startDay, endDay, pjAssignmentTimeScaledWork, daily)
for a = 1 to timeScaleValsArry.Count
timeScaleValsArry[a].value = hoursToWorkThatDay
next
Breaking down the elements above:
myTask is the task (of type task) I want to manipulate.
Assignments is an array representing each resource assigned to the task; for my purposes, I only ever had 1 resource assigned, hence the index of (1).
TimeScaleData is the function that returns the the array starting on the day startDay (whatever you want that to be), endDay, pjAssignmentTimeScaledWork which tells this function what data we want to work with (being work, but there are alternates ), and daily which is the frequency you want to work with (for instance you can go down to minutes, or up to years).
Then the returned array timeScaleValsArry is walked, and inside the loop the daily assignment for each value is manipulated. You'd need to customize this part to meet your needs; alternatively, you don't even need to loop if you always had three days: just hard code the array indices.
As far as language, clearly this is do-able in VBA. Doing this in C# as a VSTO addin has very similar syntax. I'd presume for JavaScript (what are you using, ScriptLab?) would also have similar syntax.
I am new to Flex. In my project, I use LCDS to define a holiday table which contain holidayId, countryCode and companyCode. LCDS generated all the getBy which are very handy. However, I need to get the records which are having countryCode = US AND companyCode = ABC. Surely I cannot use any of those generated getBy (each of them deals with a single field only). Can you suggest me how to modify the code in generated services (in my case, it is _Super_HolidayService.as) to handle multi-key data retrieval or point me to the right direction. Thanks.
Assuming that you're using LiveCycle's Model Driven Development, the solution is to add a filter to your Holiday entity. For example, you could add the following to the source of your Data Model (inside of your Holiday entity):
<filter name="getByCountryAndCompany" criteria="countryCode eq, companyCode eq"/>
This will create a getByCountryAndCompany method in your HolidayService that will query based on a match of both countryCode and companyCode.
Please see Adobe's Application Modeling Reference here http://tinyurl.com/7ras5yk for more information on the "filter" tag and its syntax.
Is there a way, in Axapta/Dynamics Ax, to create an Extended Data Type of type integer which only allows enering values in a specified range (i.e., if the extended data type is meant for storing years, I should be able to set a range like 1900-2100), or do I have to manage the range using X++ code?
And if I need to use X++ code to manage the range, which is the best way to do it?
I suggest you use the ''validateField'' of the corresponding table.
Search for the method in AOT\Data Dictionay\Tables to see many examples.
You can can't specify the range on the extended data type itself. If the type is used for a table field, you can add code to the insert and update methods of the table, in order to validate the value whenever the record is updated. This approach could however have a cost in terms of performance.
You can also choose to just add code the the validateWrite method of the table, if you are satisfied with the validation only taking place when the value is modified from the UI.