EcorResCategory get childrens x++ - microsoft-dynamics

I need to get all childrens (and its childrens) for a parent product category
example:
Parent
-- child 1
-- child 2
---- child 2.1
---- child 2.2
-- child 3
I am using the EcoResCategory.getChildren() method but it gets the first children only.

"but it gets the first children only"
I don't think that is correct. If you take a look at the references of the EcoResCategory.getChildren() method, there is method WarrantyLookupProcessingJob.updateLookupCategory() that shows the following pattern:
EcoResCategory childCategory = parentCategory.getChildren();
while (childCategory)
{
next childCategory;
}
The next keyword retrieves the next record from the childCategory table buffer. See also https://learn.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/dev-ref/xpp-data/xpp-select
Also note that the getChildren method has a _levelLimit parameter with the following documentation:
An <c>EcoResCategoryLevel</c> value that indicates the maximum level of children categories to retrieve.

Related

Oracle APEX Compare Two Items Values to Fire a Dynamic Action

I want to create a Dynamic Action thats when my page item P2014_BALANCE < P2014_CURRENT_PRICE then P2014_CURRENT_PRICE gets the static value 0.
The problem is that i can't compare these two page items. I try to when section in my Dynamic Action to use Javascript expression like this:
if(apex.item( "P2014_CURRENT_PRICE " ).getValue() < apex.item( "P2014_CURRENT_PRICE " ).getValue()){
alert('Wrong Number');
};
but when my page loads gets an error (even Fire on Initialization = False).
I also try this:
still nothing.
This is a web application. All page items contain string values. So if you want to do number comparison, make them numbers:
if (Number(apex.item( "P2014_BALANCE" ).getValue()) < Number(apex.item( "P2014_CURRENT_PRICE" ).getValue())) {
alert('Wrong Number');
};
Note that in your example you have P2014_CURRENT_PRICE twice - that will always yield false anyways.
This is how you would implement this in a dynamic action. Note that I tried on 21.1 but it should be similar in 5 (consider upgrading):
Dynamic Action on Change of Item P2014_CURRENT_PRICE with client Side Condition of type Javascript Expression
Source:
apex.locale.toNumber(apex.item( "P2014_CURRENT_PRICE" ).getValue()) > apex.locale.toNumber(apex.item( "P2014_BALANCE" ).getValue())
True Action with Action Set Value
Set Type Static Assignment
Value "0"
Affected Element Item P2014_CURRENT_PRICE

Is there a way to create a unordered list with subitems from 1 content-type

I would like to create a organogram like:
https://codepen.io/bernardoantunes/pen/inrbh using 2sic Content.
I would like to create a content-type 'organogram' with the following fields:
Title as String
Parent as Entity (of type Organogram)
Description as String
Link as Hyperlink
Using this content-type i would add some elements where child elements could be created.
for example:
- Root
- Child 1 (Root is selected in the Parent field)
- Child 2 (Root is selected in the Parent field)
- Child 3 (Child 2 is selected in the Parent field)
Could this be done using 2sic content App?
I created the content-type and added some elements. Created a razor template and then it gives an error.
operator '==' can not be applied to operands of type System.Collections.Generic.List and ToSic.SexyContent.DynamicEntity
Razor template:
#using Connect.Koi;
#{
var first = AsDynamic(Data["Default"]).First();
var all = AsDynamic(Data["Default"]);
}
<div>#first.Title</div>
var children = all.Where(x => x.parent == first).ToList();
<div>#children.Count</div>
Basically the AsDynamic(...) creates wrapped entity-objects, whereas ...parent gives you a list of related items (because it could have more than 1 parent). If this is the code you want to use, I suggest 1 things.
On the .parent (which should probably be .Parent) use the [0] or .FirstOrDefault() so it's .Parent.FirstOrDefault() == first - remember to enable LINQ by #using System.Linq
Don't compare the AsDynamic objects, because they will be different objects. Better compare the id using .EntityId or something.
So you're resulting compare will probably be .Parent[0].EntityId == first.EntityId.
What I don't like about your solution is the idea, that the first item in the Default-list will somehow be the important one. This doesn't feel right, but I don't know your whole solution...

COM IContextMenu::InvokeCommand - matching LPCMINVOKECOMMANDINFO::lpVerb to item

I have created a shell extension for windows with COM, however I seem to fail to properly match the ids of items I add in the overload of IContextMenu::QueryContextMenu with what I receive in the overload of IContextMenu::InvokeCommand. In my code I use InsertMenu and InsertMenuItem (as far as I understood they do the same, but the latter has some more features?). However I'm not sure which arguments passed to InsertMenu/InsertMenuItem correspond to what I must be looking for in LPCMINVOKECOMMANDINFO::lpVerb. I need some way to easily know that when I add items x, y, z to a context menu, I can then know exactly which one of x, y or z has been clicked.
EDIT: It seems that the verb equals the number from top to bottom of the item in the current menu/submenu. However I have two sub-menus each with x amount of items, so they have the same IDs of 1,2,3. How do I set custom IDs or something?
Firstly you should define an enum that holds the command IDs for your menu items, e.g.
enum {
CMDID_FIRST = 0,
CMDID_DOSOMETHING = CMDID_FIRST,
CMDID_DOSOMETHINGELSE,
CMDID_LAST,
};
These ID values need to start from 0.
In your IContextMenu::QueryContextMenu implementation:
when you add your menu items you need to give each of them an ID by setting the MIIM_ID flag in the MENUITEMINFO.fMask field, and setting the MENUITEMINFO.wID value.
give each of your menu items an ID derived from its command ID as defined above, plus the value of idCmdFirst which is passed into QueryContextMenu. E.g. the "Do Something" menu item would have MENUITEMINFO.wID set to idCmdFirst + CMDID_DOSOMETHING, and "Do Something Else" would have MENUITEMINFO.wID set to idCmdFirst + CMDID_DOSOMETHINGELSE.
the return value from QueryContextMenu needs to be MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, x) where x is the ID of the highest-numbered item you added plus 1 (alternatively, if all items were sequentially numbered, the total number of items). Basically, you're telling the host which menu item ID values are now in use so that no other context menu extensions add items that clash with yours. In the above example, you'd return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, CMDID_LAST).
In IContextMenu::InvokeCommand:
test if lpVerb (or lpVerbW) is an integer value using the IS_INTRESOURCE macro.
if so, the command ID can be found in the low word. E.g, if the user selected "Do Something Else", you would find that LOWORD(lpVerb) == CMDID_DOSOMETHINGELSE.

What is difference between getElementsByTagName() with tagName and with .//tagName?

What is difference between getElementsByTagName() with tagName and with .//tagName ?
When we pass tagname in the getElementsByTagName(), in that what is the meaning when we add ".//" ?
What is the difference between
sSourceInputXml->
getElementsByTagName(_bstr_t(".//author"), &xml2);
and
sSourceInputXml->
getElementsByTagName(_bstr_t("author"), &xml2);
?
Both return me same number of elements.
Any help is appreciated.
// means location step descendant-or-self:node(), which retrieves the current node and all its descendants.
. means self::node() which gets the context node.
Default location step is child, which gets the child elements of the context node.
If you need more information, check here.

To check if the first child node is a processing instruction or not

I want a code snippet to check if the first child node is a processing instruction or not?
For example :
<caml:Author>
<?PI-start data="processing instruction"?>
<caml:Leg> test data </caml:Leg>
</caml:Author>
In the above example the first child node of caml:Author tag is a processing instruction. How can I find if the first child node is a processing instruction ?
Remembering that you could also get comments or text nodes (the first child node of in your example is a text node), then if caml:Author is my current node, I would use the following to address the children:
test="(processing-instruction() | *)[1][self::processing-instruction()]"
The result is true if the first of the processing-instruction and element children is a processing-instruction.