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
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (4,556)