AX2009 manual NumSeq on business relation? - axapta

Anyone know why the number sequence on business relation (AX 2009) should not be manual, according to basic code?
Table method smmBusRelTable.checkNumberSequence()
if (numberSequenceReference)
{
numberseq = NumberSequenceTable::find(numberSequenceReference.NumberSequence);
if (numberseq)
{
if (numberseq.Manual)
{
// Business relation number sequence must not be manual
ret = checkFailed("#SYS81360");
}
}
...
Manual can be used, but of course the warning "Business relation number sequence must not be manual" will pop up everytime.

My guess is it was written in some spec, that prospects should have an automatic number sequence.
Also AX users rarely cares about the number of a prospect, but may care about the number of the customer, maybe using phone numbers or something else. Prospect are usually imported from external sources and there may be 10 or 1000 more prospects than customers.

Related

Iteration over VendTransOpen

This happens in Accounts Payable -> Journals -> Payments -> Payment Journal.
I choose to see the Lines for a journal and from Functions I select Settlement. I am not sure if this is the same for everyone else.
So, when clicking Settlement, VendOpenTrans opens. I need to iterate over it, and Mark the records according to the invoice of the previously selected LedgerJournalTrans field.
First of all I have to check the VendOpenTrans fields which I am not able to accomplish.
I have added the following piece of code in the init of VendTransOpen:
VendTrans vt;
vt = vendTransOpen_ds.getFirst(true) as VendTrans ;
while (vt)
{
//Do your thing
vt= vendTransOpen_ds.getNext() as VendTrans ;
}
No elements seem to be present in the vendTransOpen_ds..
Can someone give me a hint about this?
Update 1:
Found this :
Understanding the Settlement Mechanism in Microsoft Dynamics AX
and
Automatic mark a Settlement Transactions on a Payment Journal in AX 2012
I didn't think it would be so damn difficult.. I will start digging tomorrow.
Several things are wrong, but probably my #2 is your main problem.
If you place this code in the init method, the query hasn't been executed yet, so nothing will be there. See https://msdn.microsoft.com/en-us/library/aa608211.aspx
Your code will never enter while (vt) because vt will never have a value as written because VendTrans and VendTransOpen are two different tables that don't support inheritance.
The only reason vt = vendTransOpen_ds.getFirst(true) as VendTrans ; doesn't throw an error is because FormDataSource.getFirst()/getNext() returns a Common table record.
What Jan said too.
First off, use getFirst(0) before using getNext().
The zero indicates you want all records rather than marked.
Search, use cross reference tool, or google to get lots of references for the use of these functions.

Graph DB get the next best recommended node in Neo4j cypher

I have a graph using NEO4j and currently trying to build a simple recommendation system that is better than text based search.
Nodes are created such as: Album, People, Type, Chart
Relationship are created such as:
People - [:role] -> Album
where roles are: Artist, Producer, Songwriter
Album-[:is_a_type_of]->Type (type is basically Pop, Rock, Disco...)
People -[:POPULAR_ON]->Chart (Chart is which Billboard they might have been)
People -[:SIMILAR_TO]->People (Predetermined similarity connection)
I have written the following cypher:
MATCH (a:Album { id: { id } })-[:is_a_type_of]->(t)<-[:is_a_type_of]-(recommend)
WITH recommend, t, a
MATCH (recommend)<-[:ARTIST_OF]-(p)
OPTIONAL MATCH (p)-[:POPULAR_ON]->()
RETURN recommend, count(DISTINCT t) AS type
ORDER BY type DESC
LIMIT 25;
It works however, it easily repeats itself if it has only one type of music connected to it, therefore has the same neighbors.
Is there a suggested way to say:
Find me the next best album that has the most similar connected relationships to the starting Album from.
Any Recommendation for a tie breaker scenario? Right now it is order by type (so if an album has more than one type of music it is valued more but if everyone has the same number, there is no more
significant)
-I made the [:SIMILAR_TO] link to enforce a priority to consider that relationship as important, but I haven't had a working cypher with it
-Same goes for [:Popular_On] (Maybe Drop this relationship?)
You can use 4 configurations and order albums according to higher value in this order. Keep configuration between 0 to 1 (ex. 0.6)
a. People Popular on Chart and People are similar
b. People Popular on Chart and People are Not similar
c. People Not Popular on Chart and People are similar
d. People Not Popular on Chart and People are Not similar
Calculate and sum these 4 values with each album. Higher the value, higher recommended Album.
I have temporarily made config as a = 1, b =0.8, c=0.6, d = 0.4. And assumed some relationship present which suggests some People Likes Album. If you are making logic based on Chart only then use a & b only.
MATCH (me:People)
where id(me) = 123
MATCH (a:Album { id: 456 })-[:is_a_type_of]->(t:Type)<-[:is_a_type_of]-(recommend)
OPTIONAL MATCH (recommend)<-[:ARTIST_OF]-(a:People)-[:POPULAR_ON]->(:Chart)
WHERE exists((me)-[:SIMILAR_TO]->(a))
OPTIONAL MATCH (recommend)<-[:ARTIST_OF]-(b:People)-[:POPULAR_ON]->(:Chart)
WHERE NOT exists((me)-[:SIMILAR_TO]->(b))
OPTIONAL MATCH (recommend)<-[:LIKES]-(c:People)
WHERE exists((me)-[:SIMILAR_TO]->(a))
OPTIONAL MATCH (recommend)<-[:LIKES]-(d:People)
WHERE NOT exists((me)-[:SIMILAR_TO]->(a))
RETURN recommend, (count(a)*1 + count(b)*0.8 + count(c)* 0.6+count(d)*0.4) as rec_order
ORDER BY rec_order DESC
LIMIT 10;

Cleaning up unused Customers

I am being asked to clean unused Customers in our AX database. The challenge is defining "unused" of course.
Is there any diagram anywhere documenting the table's relationship in Dynamics AX 2009 ?
For example, I see the table LedgerJournalTrans has the "AccountNum" field. I guess I could extrapolate that if a Customer has no associated records in LedgerJournalTrans, it is unused but I think it may be a bit more complicated than this.
Anything else I should watch for ?
Thanks!
I have had to do this before, and it really isn't terribly challenging, you just have to do your due diligence. I wouldn't feel as confident with ian_scho's method because it only checks two tables, but I'd say his method gets the 80%.
I would say your best method is to copy the class Classes\InventUnusedDimCleanUp and modify the simple functions in the \run method.
This is a base class that basically does the following, except I'm going to substitute InventDimId with AccountNum for solidarity:
Insert every customer account (AccountNum) into an empty check table as a starting reference
Traverse the Data Dictionary\Tables tree node over every table in the AOT
While traversing, determine if the table is a candidate table to compare against
If it is a candidate table, then traverse each field and determine if it's a candidate field by checking if it is an EDT of CustAccount or an EDT that extends it
If we determine it is a candidate field, then insert that into our container list of [TableId,FieldId]s
Next, loop through the container and for each tableId/fieldId, delete from our check table AccountNum's that DO exist in the candidate tables, so that we will be left with a check table of AccountNum's that were not found in any table
Lastly, a step you will probably do manually, but it will delete from CustTable the customers that are remaining in the check table, which have been deemed unused
This should accomplish your task, but doesn't take in account any external systems or customization you may have...but it gets the 95%.
Don't forget customer transactions - In one company or across all of them?
And in AX 2012 the financial dimension framework may reference the customer table itself.
CustTable custTable;
CustTrans custTrans;
//DefaultDimensionView defaultDimensionView; // **AX 2012**
;
//Customer transactions not found.
setPrefix("#SYS119665");
while select crossCompany AccountNum, Party from custTable
notExists join custTrans
where custTable.AccountNum == custTrans.AccountNum
{
info (strFmt("%1 - %2", custTable.AccountNum, custTable.name()));
//// Check financial dimension definition, 'Customer' **AX 2012**
//select firstonly defaultDimensionView
// where defaultDimensionView.DisplayValue == custTable.AccountNum
// && defaultDimensionView.Name == "Customer"; //"Client" in some countries? May depend upon AX installation.
//if (defaultDimensionView)
//{
// warning("Financial dimension value exists.");
//}
}
Personally I'd advise against deleting ANYTHING on these systems. Produce a report about what percentage of master data is being used, and if the data negatively impacts on usability...
Then see if your boss forgets about the request :)

Votingapi and vote up/down question

I have some nodes with a widget vote up/down. I can't understand how can i get integer votes value for various actions without sql requery. For example to hide nodes with rating < 10.
No matter what module you use,(Rate, Fivestar or anything else), all the data stored in Voting API module.
Using Rules module and VotingAPI Rules integration module you can check values of votes and take arbitrary(but possible) actions.
You may need to add new triggered rule on even "user votes on content" and check if the vote's value is < 10.
Voting API keeps data as a percentage so < 10 means < 10%. Vote count, value of each vote and percentage available as data.

Ads System

I am creating an Ad system for an ASP.NET website. The website has a section for advertisers. They register their and posts there ads, They will pay the maximum budget for the ad first, There is a daily budget , so the advertiser can control his budget, There will be a lot of ads from different advertisers to show in the website. The ads has two attributes maximum budget and daily budget, How can i select ads , How many times an ad can display, Can anyone give me a method or algorithm for that.
Hey Priyan,
here's how we handle it in AdServerBeans (http://www.adserverbeans.com - it's open source, you can check the source code):
DROP FUNCTION if exists get_speed;
CREATE FUNCTION get_speed(from_date DATETIME, to_date DATETIME, views_limit INT, views_served INT, now_date_time TIMESTAMP)
RETURNS double
DETERMINISTIC
NO SQL
BEGIN
DECLARE banner_total_serving_time INTEGER;
DECLARE banner_served_time INTEGER;
DECLARE percent_time_served DOUBLE;
DECLARE percent_ad_events_served DOUBLE;
IF (views_limit IS NULL OR views_limit=0) THEN RETURN -1;END IF;
IF (views_served IS NULL) THEN SET views_served = 0;END IF;
IF (banner_total_serving_time = 0) THEN SET banner_total_serving_time = 1;END IF;
IF (views_limit = 0) THEN SET views_limit = 1;END IF;
SET banner_total_serving_time = TIMESTAMPDIFF(SECOND, from_date, to_date);
SET banner_served_time = TIMESTAMPDIFF(SECOND, from_date, now_date_time);
SET percent_time_served = (100 * banner_served_time) / banner_total_serving_time;
SET percent_ad_events_served = (100 * views_served) / views_limit;
RETURN percent_ad_events_served - percent_time_served;
END
;;
This MySQL function returns negative or positive number. Negative if we are underperforming, positive if overperforming.
Underperforming - serve, overperforming - skip to the next banner or not serve.
Input parameters are self-explanatory I hope.
I would recommend looking at scheduling algorithms.
For example, you could use the budget to determine a number of times / period (day/week/etc), and use that as a weighting factor in a weighted round robin schedule. This would be a simple way to balance out requests from different advertisers evenly through time. (NOTE: The link above is more geared towards network packet scheduling, but the basic algorithm would work...)
I think you should use different algorithms for your problem. Normally in that kind of systems you have:
ASAP (The campaign will be shown as soon as possible without limitation)
Even distribution/redistribute if overdelivered (The campaign's traffic will be evenly distributed through the indicated period of time. If the campaign is overdelivered due to any modification, a new traffic distribution will be calculated so the remaining traffic amount is evenly distributed in the remaining period of time)
Even distribution in two halves (The even distribution in two halves function is similar to the even distribution/redistribute option. However, it allows the user to assign an amount of traffic to the first half of the campaign and another to the second half. The halves are calculated by taking into account the total duration of the campaign, its weekly timetable and its multiple begin and end dates, if applicable. Then, the system takes the total amount of traffic, multiplies it by the corresponding percentage set for each half, and assigns it uniformly within each half.)
Adaptable even distribution (Traffic will be assigned according to traffic distribution of the sites where the campaign will run. More traffic will be assigned to peak hours and less to off-peak hours. When campaign is near its schedule end date, traffic distribution will be accelerated to ensure that goals are met.)
If too many algorithms is something which you do not want to deal, then implement only ASAP, I mean if that an advertiser can win he will win still his daily budget is over

Resources