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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (3,241)