cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JohnM86
Helper II
Helper II

Model Driven app is not saving selected data / or showing all related contacts in the gallery

Hi 

 

I have a modeldriven app used as a crm, occasionally when inputting data directly via the crm the app removes the account data upon saving. 

 

JohnM86_0-1653582177699.png

 

 

I have created a canvas app to embed into an intranet however when saving the data from the app this constantly removes the account information leaving the information as detailed above. 

 

JohnM86_1-1653582279930.png

 

As you can see from the image above the data is gathered correctly but when I click save it removes the account data causing the flow to fail.

 

The code used is detailed below

 

If(
(lvarCrrStg = 4 And CountRows(
Filter(
collPrgStages,
StatusFlag = 2
)
) =3),
Patch(Projects,
Defaults(Projects),
{
'🛠️ Project Name':projectname.Text,
'Job Cost Limit':Value( costs.Text),
'📅 Start Date': 'start date'.SelectedDate,
'📅 Dead Line': deadlinedate.SelectedDate,
'Urgent Request': urgentreq.Selected.Value,
'Is CIS ?': iscis.Selected.Value,
'⚙️ Project Category': category.Selected,
'🏢 Property': property.Selected,
'🏢 Account': Gallery3.Selected,
'👤 Project Contact': Gallery4.Selected,
'Employee (crffc_Employee)': Gallery3_1.Selected,
Contractor: Gallery4_1.Selected,
'📋 Description': projdesc.Text

})
;
Notify("Project details submitted successfully!", NotificationType.Success);
UpdateContext({lvarSubmitted: true})
);
If(
lvarCrrStg=3,
If(
IsBlank(projectname.Text),
UpdateContext({lvarprojectnameEmpty:true}),
UpdateContext({lvarprojectnameEmpty:false})
);
If(
IsBlank(costs.Text),
UpdateContext({lvarcostsEmpty:true}),
UpdateContext({lvarcostsEmpty:false})
);
If(
IsBlank(projdesc.Text),
UpdateContext({lvarprojdescEmpty:true}),
UpdateContext({lvarprojdescEmpty:false})
);
If(
IsBlank(projacclabel.Text),
UpdateContext({lvarprojacclabelEmpty:true}),
UpdateContext({lvarprojacclabelEmpty:false})
);
If(
IsBlank(projcontlabel.Text),
UpdateContext({lvarprojcontlabelEmpty:true}),
UpdateContext({lvarprojcontlabelEmpty:false})
);
If(
IsBlank(Gallery3.Selected),
UpdateContext({lvarGallery3Empty:true}),
UpdateContext({lvarGallery3Empty:false})
);
If(
IsBlank(Gallery4.Selected),
UpdateContext({lvarGallery4Empty:true}),
UpdateContext({lvarGallery4Empty:false})
);
If(
IsBlank(emplabel.Text),
UpdateContext({lvaremplabelEmpty:true}),
UpdateContext({lvaremplabelEmpty:false})
);
If(
IsBlank(projdesc.Text),
UpdateContext({lvaremplabelEmpty:true}),
UpdateContext({lvaremplabelEmpty:false})
);
If(
lvarprojectnameEmpty || lvarcostsEmpty || lvarprojdescEmpty || lvarprojacclabelEmpty || lvarprojcontlabelEmpty || lvarGallery3Empty || lvarGallery4Empty || lvaremplabelEmpty || lvarprojdescEmpty,
Patch(
collPrgStages,
LookUp(
collPrgStages,
ID = lvarCrrStg
),
{
StatusFlag: 0,
IsCrrStage: false
}
);
Patch(
collPrgStages,
LookUp(
collPrgStages,
ID = lvarCrrStg + 1
),
{IsCrrStage: true}
),
Patch(
collPrgStages,
LookUp(
collPrgStages,
ID = lvarCrrStg
),
{
StatusFlag: 2,
IsCrrStage: false
}
);
Patch(
collPrgStages,
LookUp(
collPrgStages,
ID = lvarCrrStg + 1
),
{IsCrrStage: true}
)
)
);
UpdateContext(
{
lvarCrrStg: If(
lvarCrrStg + 1 <= CountRows(collPrgStages),
lvarCrrStg + 1,
4
)
}
)

 

also i have two galleries one with the accounts in and another with related contacts - the issue with this is the accounts show fine but only a few accounts will show the related contacts with others showing as blank (image below)

 

JohnM86_2-1653582590904.pngwithout contact

JohnM86_3-1653582724297.pngwith contact

 

 

the code for the gallery filter is 

 

Filter(Contacts, AsType('Company Name',[@Accounts]).'🏢 Account Name' = Gallery3.Selected.'🏢 Account Name')

 

with this information, i was hoping you gurus out there would be able to point me in the right direction to where i am going wrong 😄

 

thank you in advance

 

 

 

21 REPLIES 21
jcfDaniel
Super User
Super User

In your code that validation is after the patch, or am I reading it wrong?


Regards. JD.
JohnM86
Helper II
Helper II

This is the whole patch code 

 

If(
(lvarCrrStg = 4 And CountRows(
Filter(
collPrgStages,
StatusFlag = 2
)
) =3),
Patch(Projects,
Defaults(Projects),
{
'

JohnM86_0-1653993421184.png

 

️ Project Name':projectname.Text,
'Job Cost Limit':Value( costs.Text),
'

JohnM86_1-1653993421187.png

 

 Start Date': 'start date'.SelectedDate,
'

JohnM86_2-1653993421187.png

 

 Dead Line': deadlinedate.SelectedDate,
'Urgent Request': urgentreq.Selected.Value,
'Is CIS ?': iscis.Selected.Value,
'

JohnM86_3-1653993421187.png

 

 Project Category': category.Selected,
'

JohnM86_4-1653993421188.png

 

 Property': property.Selected,
'

JohnM86_5-1653993421188.png

 

 Account': Gallery3.Selected,
'

JohnM86_6-1653993421188.png

 

 Project Contact': Gallery4.Selected,
'Employee (crffc_Employee)': Gallery3_1.Selected,
Contractor: Gallery4_1.Selected,
'

JohnM86_7-1653993421189.png

 

 Description': projdesc.Text

})
;
Notify("Project details submitted successfully!", NotificationType.Success);
UpdateContext({lvarSubmitted: true})
);

 

as you see it will only patch if lvarstg has reached 4 and there are no blanks

JohnM86
Helper II
Helper II

the issue does not seem to lie with the patch because all other details submit perfectly fine - the issue seems to be  for some reason the model-driven app keeps removing the account record upon submission

JohnM86
Helper II
Helper II

So I have swapped a few things around to enable adding in contacts however, I decided to try using a form,

 

JohnM86_0-1654027797757.png

preset form 

JohnM86_1-1654027816320.png

model driven app after form submission - still missing account details 

 

to add in the accounts via a preset dropdown and still get the same issue with a form as I do with the custom fields. This is getting really confusing 😕 does anyone have any ideas about what may be going wrong?

jcfDaniel
Super User
Super User

Are you sure you have no workflow running on these records or something of that sort.

 

IF you a look at a brand new record, what do the dates tell you? Look at created on and modified on

 

There's got to be something going on.


Regards. JD.
JohnM86
Helper II
Helper II

the only flow is to auto send an email to the account contact and employee when the data is added - because the account data doesn't fill, the flow to the account contact fails (relies on the account field being filled) but the email to the employee completes no issues 

the account email fails with : The 'inputs.parameters' of workflow operation 'Get_a_row_by_ID' of type 'OpenApiConnection' is not valid. Error details: The resolved string values for the following parameters are invalid, they may not be null or empty: 'recordId' this is because it is not populating the account field 

created and modified dates are set to the same date and time 

JohnM86
Helper II
Helper II

on checking the monitor it appears everything is running successfully yet still no population of the account field 

 

JohnM86_0-1654030590439.png

 

JohnM86
Helper II
Helper II

after checking the formula in the monitor it shows the account as null 

 "_fw_account_value"null, although it doesn't detect any errors 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,584)