Solved

FSM Connect - Elements the same value.


Userlevel 5
Badge +14

Hi,

 

The end point I am wanting to post to is expecting some custom values to be sent with a repeating element name of customfieldname and customfieldvalue. I have three to pass in this example.

 

The XML structure in the log is correct. However the value for the ‘customfieldvalue’ is only picking up the quantity and placing that in the first customfieldname.

 

                            <customfields>
                                <customfield>
                                    <customfieldname>FSM_PART_NUMBER</customfieldname>
                                    <customfieldvalue>1.0000000000</customfieldvalue>
                                </customfield>
                                <customfield>
                                    <customfieldname>SUPPLIER_PART_NUMBER</customfieldname>
                                    <customfieldvalue />
                                </customfield>
                                <customfield>
                                    <customfieldname>QUANTITY</customfieldname>
                                    <customfieldvalue />
                                </customfield>
                            </customfields>

 

Based on some previous requests and setups I have done I am expecting the need to use an xml_template, and I think it might be a case of getting that right.

 

In FSM I have the XML extract set up like so;

 

With the following in the xml_template in the customfields row.

                                <customfield>
                                    <customfieldname>FSM_PART_NUMBER</customfieldname>
                                    <customfieldvalue>[@part_id]</customfieldvalue>
                                </customfield>

 

Without this, I think the Part ID and Suppliers Part ID just get skipped and the Quantity is passed on it’s own.

 

What do I need to change to get to the end goal?

 

Regards


Ady

 

icon

Best answer by SAMLK 18 April 2024, 04:48

View original

10 replies

Userlevel 4
Badge +12

Hi Ady,

The FSM integration framework will not recognize repeating elements unless a parent-child relationship is defined in your XML map.

Therefore, as a workaround for this issue, you can define three dummy relationships (based on your example) on the relationships tab and include them in your XML map, as shown in the following example. 

defining the 3 dummy relationships
calling them in the xml map

The formatted result,  

<?xml version="1.0" encoding="UTF-8"?>
<request>
<customfields>
<customfield>
<customfieldname>FSM_PART_NUMBER</customfieldname>
<customfieldvalue>612</customfieldvalue>
</customfield>
</customfields>
<customfields>
<customfield>
<customfieldname>SUPPLIER_PART_NUMBER</customfieldname>
<customfieldvalue>1234</customfieldvalue>
</customfield>
</customfields>
<customfields>
<customfield>
<customfieldname>QTY</customfieldname>
<customfieldvalue>200</customfieldvalue>
</customfield>
</customfields>
</request>

 

Userlevel 5
Badge +14

Hi @SAMLK 

That’s fantastic and to an extent produces the XML as you have laid out.

However how would I get that all inside one <customfields> </customfields> set of tags?

Example;

<?xml version="1.0" encoding="UTF-8"?>
<request>
<customfields>
<customfield>
<customfieldname>FSM_PART_NUMBER</customfieldname>
<customfieldvalue>612</customfieldvalue>
</customfield>

<customfield>
<customfieldname>SUPPLIER_PART_NUMBER</customfieldname>
<customfieldvalue>1234</customfieldvalue>
</customfield>

<customfield>
<customfieldname>QTY</customfieldname>
<customfieldvalue>200</customfieldvalue>
</customfield>
</customfields>
</request>
Userlevel 4
Badge +12

Hi @SAMLK 

That’s fantastic and to an extent produces the XML as you have laid out.

However how would I get that all inside one <customfields> </customfields> set of tags?

Example;

<?xml version="1.0" encoding="UTF-8"?>
<request>
<customfields>
<customfield>
<customfieldname>FSM_PART_NUMBER</customfieldname>
<customfieldvalue>612</customfieldvalue>
</customfield>

<customfield>
<customfieldname>SUPPLIER_PART_NUMBER</customfieldname>
<customfieldvalue>1234</customfieldvalue>
</customfield>

<customfield>
<customfieldname>QTY</customfieldname>
<customfieldvalue>200</customfieldvalue>
</customfield>
</customfields>
</request>

Hi Ady,

Sorry I have missed that part in my example. You can do a small adjustment like this on your map’s primary xpath, relationship xpath and to your map’s xpath as below. There can be different other ways, but this was the one I came up with just a few seconds ago :)

primary path and extract xpaths changed
your map

final result,

<?xml version="1.0" encoding="UTF-8"?>
<request>
<customfields>
<customfield>
<customfieldname>FSM_PART_NUMBER</customfieldname>
<customfieldvalue>612</customfieldvalue>
</customfield>
<customfield>
<customfieldname>SUPPLIER_PART_NUMBER</customfieldname>
<customfieldvalue>1234</customfieldvalue>
</customfield>
<customfield>
<customfieldname>QTY</customfieldname>
<customfieldvalue>200</customfieldvalue>
</customfield>
</customfields>
</request>

 

Userlevel 4
Badge +12

Adding more information on the same subject in which I thought would be useful..

It’s not necessarily required to have 3 relationships in your map as the primary table relationship itself stands out as a unique relation in the xml map. :) So in your case, you can leave the first two fields as it is and then apply the two relationships correspondingly. It will still give you the correct end result.

 

Userlevel 5
Badge +14

@SAMLK 

That’s great and by doing that I have the output I require, But there is a bit but.

I’m ultimately wanting to post purchase detail lines. This is fine with a single line item and I have it posting with a success to the 3rd Party.

However when there are multiple items the XML works back from the primary path.

/request/operation/content/function/create_bill/billitems/lineitem/customfields

So if I have two parts. the custom fields so as per below, with the rest of the XML around that.

                            <customfields>
                                <customfield>
                                    <customfieldname>FSM_PART_NUMBER</customfieldname>
                                    <customfieldvalue>8323LGR</customfieldvalue>
                                </customfield>
                                <customfield>
                                    <customfieldname>SUPPLIER_PART_NUMBER</customfieldname>
                                    <customfieldvalue>8323AGNV</customfieldvalue>
                                </customfield>
                                <customfield>
                                    <customfieldname>QTY</customfieldname>
                                    <customfieldvalue>1.0000000000</customfieldvalue>
                                </customfield>
                            </customfields>
                            <customfields>
                                <customfield>
                                    <customfieldname>FSM_PART_NUMBER</customfieldname>
                                    <customfieldvalue>8323MWBL</customfieldvalue>
                                </customfield>
                                <customfield>
                                    <customfieldname>SUPPLIER_PART_NUMBER</customfieldname>
                                    <customfieldvalue>8323ASMRL1A</customfieldvalue>
                                </customfield>
                                <customfield>
                                    <customfieldname>QTY</customfieldname>
                                    <customfieldvalue>1.0000000000</customfieldvalue>
                                </customfield>
                            </customfields>

 

I’d need to have each part listed under lineitem and the custom fields a child of that.

 

How can I keep the XML structure for the custom fields we have above, but set them after the lineitem individually?

If I revert the primary path back, then I am back to square one again in that i’m creating multiple customfields entries.

 

I’m close, just no cigar.

 

Ady

Userlevel 4
Badge +12

Hi Ady,

I’m also running out of ideas for this specific requirement unfortunately. :( I thought the xml structure was a fixed one initially. Most likely, this is going to be a code level enhancement as we cannot repeat the same element in a dynamically structured relationship in the fsm integration framework. 

Userlevel 5
Badge +14

@SAMLK not a problem at all.

You have been a great help and the engagement was appreciated. We were almost there!

I will see what our project team want to do, and look at all the alternatives.

 

Thanks again


Ady

Userlevel 4
Badge +12

@AdrianEgley  glad I could help you up to a certain extent. I will let you know in case if I found a workaround (highly doubt it) 

Userlevel 5
Badge +14

@SAMLK 

We were on the right track.

Had fresh pot of coffee and got stuck into this again.

I updated the extract path on the relation definitions so we would go to the next level on the XML.

Then on the mapping remove the /customfield so I was going straight to the map I needed

 

The output for multi part PO’s were looking spot on.

 

Thanks again, between you and the coffee we got there :D 

 

Ady

Userlevel 4
Badge +12

@SAMLK

We were on the right track.

Had fresh pot of coffee and got stuck into this again.

I updated the extract path on the relation definitions so we would go to the next level on the XML.

Then on the mapping remove the /customfield so I was going straight to the map I needed

 

The output for multi part PO’s were looking spot on.

 

Thanks again, between you and the coffee we got there :D 

 

Ady

Oh this is great Ady.. Glad you could figure out the final part !!!! :D

Reply