cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
johnc222
Helper III
Helper III

Only carrying over one var to JSON

Hello - I am certain I am doing something wrong here in my logic,

 

Currently if I have more than one 'selected' railcar it will only carry over data for the last one here is my code. Not sure how to better arrange this 

 

If(!IsBlank(B211INBOUND.Selected.Railcar),
    UpdateIf('374 Staged', Track = "B211-1",
        {Railcar:B211INBOUND.Selected.Railcar, 
        Status: {Value:"FULL"}}
    );
    Patch('374 MECL',
        LookUp('374 MECL', Railcar = B211INBOUND.Selected.Railcar),
        {Spot: {Value: "B211-1"}}
    );

);
If( !IsBlank(B211OUTBOUND.Selected.Railcar) && !StatusToggleB211.Value,
    UpdateIf('374 Staged', Track = "B211-1",
        {Railcar: "", Status: {Value:"MT"}}
    );
    UpdateIf('374 MECL', Railcar = B211OUTBOUND.Selected.Railcar,
        {Status: {Value: "MT"}, 
         Spot:{Value: "OUTBOUND"}
        }
    ),
    ! IsBlank(B211OUTBOUND.Selected.Railcar),
        UpdateIf('374 MECL', Railcar = B211OUTBOUND.Selected.Railcar,
            {Status: {Value: "FULL"},
            Spot:{Value: "YARD"}
            }
        );
        UpdateIf('374 Staged', Track = "B211-1",
            {Railcar: "", Status: {Value:"MT"}}
        );
);

If(!IsBlank(B2171INBOUND.Selected.Railcar),
    UpdateIf('374 Staged', Track = "B217-1",
        {Railcar:B2171INBOUND.Selected.Railcar, 
        Status: {Value:"MT"}}
    );
    Patch('374 Byproduct Cars',
        LookUp('374 Byproduct Cars', Railcar = B2171INBOUND.Selected.Railcar),
        {Spot: {Value: "B217-1"}}
    );
);

If( !IsBlank(B2171OUTBOUND.Selected.Railcar) && !StatusToggleB2171.Value,
    UpdateIf('374 Staged', Track = "B217-1",
        {Railcar: "", Status: {Value:"MT"}}
    );
    UpdateIf('374 Byproduct Cars', Railcar = B2171OUTBOUND.Selected.Railcar,
        {Status: {Value: "MT"}, 
         Spot:{Value: "YARD"}
        }
        
    ),
    ! IsBlank(B2171OUTBOUND.Selected.Railcar),
        UpdateIf('374 Byproduct Cars', Railcar = B2171OUTBOUND.Selected.Railcar,
            {Status: {Value: "FULL"},
            Spot:{Value: "YARD"}
            }
        );
        UpdateIf('374 Staged', Track = "B217-1",
            {Railcar: "", Status: {Value:"MT"}}
        );
);


If(!IsBlank(B2172INBOUND.Selected.Railcar),
    UpdateIf('374 Staged', Track = "B217-2",
        {Railcar:B2172INBOUND.Selected.Railcar, 
        Status: {Value:"MT"}}
    );
    Patch('374 Byproduct Cars',
        LookUp('374 Byproduct Cars', Railcar = B2172INBOUND.Selected.Railcar),
        {Spot: {Value: "B217-2"}}
    );
);

If( !IsBlank(B2172OUTBOUND.Selected.Railcar) && !StatusToggleB2172.Value,
    UpdateIf('374 Staged', Track = "B217-2",
        {Railcar: "", Status: {Value:"MT"}}
    );
    UpdateIf('374 Byproduct Cars', Railcar = B2172OUTBOUND.Selected.Railcar,
        {Status: {Value: "MT"}, 
         Spot:{Value: "YARD"}
        }
    ),
    ! IsBlank(B2172OUTBOUND.Selected.Railcar),
        UpdateIf('374 Byproduct Cars', Railcar = B2172OUTBOUND.Selected.Railcar,
            {Status: {Value: "FULL"},
            Spot:{Value: "YARD"}
            }
        );
        UpdateIf('374 Staged', Track = "B217-2",
            {Railcar: "", Status: {Value:"MT"}}
        );
);
 
Set(B211IN,B211INBOUND.Selected.Railcar);
Set(B211OUT,B211OUTBOUND.Selected.Railcar);
Set(B2171IN,B2171INBOUND.Selected.Railcar);
Set(B2171OUT,B2171OUTBOUND.Selected.Railcar);
Set(B2172IN,B2172INBOUND.Selected.Railcar);
Set(B2172OUT,B2172OUTBOUND.Selected.Railcar);

ClearCollect( FlowVars,
    { B211IN: B211IN},
    { B211OUT: B211OUT},
    { B2171IN: B2171IN},
    { B2171OUT: B2171OUT},
    { B2172IN: B2172IN},
    { B2172OUT: B2172OUT }
);

Set(JSONdata, FlowVars );

'374RailFlow2'.Run(JSON(JSONdata, JSONFormat.Compact));

Believe it has something to do with the way I am using Selected.Railcar only carrying over one piece of info into the vars 

1 REPLY 1
v-bofeng-msft
Community Support
Community Support

Hi @johnc222 :

Could you check the value of FlowVars? Do you need a 6X6 table or just a record with 6 fields?

In addition,could you tell me what the meaning of " only carrying over one piece of info into the vars" is?Could you display expected results and actual results?

May be you could try:

Set(B211IN,B211INBOUND.Selected.Railcar);
Set(B211OUT,B211OUTBOUND.Selected.Railcar);
Set(B2171IN,B2171INBOUND.Selected.Railcar);
Set(B2171OUT,B2171OUTBOUND.Selected.Railcar);
Set(B2172IN,B2172INBOUND.Selected.Railcar);
Set(B2172OUT,B2172OUTBOUND.Selected.Railcar);

Set(JSONdata,
    { B211IN: B211IN,
      B211OUT: B211OUT,
      B2171IN: B2171IN},
      B2171OUT: B2171OUT,
      B2172IN: B2172IN,
      B2172OUT: B2172OUT 
     }
);

'374RailFlow2'.Run(JSON(JSONdata, JSONFormat.Compact));

Best Regards,

Bof

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,302)