SDK Error when creating new Page

0
Thru trial and error I thought I was finally getting somewhere with creating a new page via the SDK, however updating the project in the Modeler resulted in an error.  I then attempted to implement something I saw in another thread https://community.mendix.com/link/questions/87576, but I believe I am not using the suggested workaround correctly or there is something else I am still doing wrong.   This is what I am attempting to test and includes the suggested workaround from the other forum question I mentioned. I get the same error in Modeler rather I attempt to use the createlayoutArgument modified or not.. So I am starting to feel I am not passing the correct FolderBase or still not understanding the correct process for creating a new page?   .. .. .. .. let project = new Project(client, projectId, projectName); project.createWorkingCopy() .then((workingCopy) => { // Get working module const module = workingCopy.model().allModules().filter(m => m.name === moduleName)[ 0 ]; // Get FolderBase from pre-existing page const fbase = module.model.allDocuments().filter(d => d.structureTypeName === 'Pages$Page') .filter(p => p.name === pageName)[0].containerAsFolderBase generate(fbase,workingCopy.model()) return workingCopy; }) .then(workingCopy => workingCopy.commit()) .done(() => { console.log(`success!`); }, (error) => { console.log(`error: ${error}`); }); export function createLayoutArgument(layoutCall: pages.LayoutCall, name: string) { const result = pages.LayoutCallArgument.createIn(layoutCall); (result as any)["__parameter"].updateWithRawValue(layoutCall.layoutQualifiedName + "." + name); return result; } function generate(unit, model) { .. .. .. .. .. .. //var layoutCallArgument1 = pages.LayoutCallArgument.create(model); var layoutCallArgument1 = createLayoutArgument(model,"groupbox_findme"); layoutCallArgument1.widget = groupBox1; var layoutCall1 = pages.LayoutCall.create(model); layoutCall1.layout = model.findLayoutByQualifiedName("NavigationLayouts.Sidebar_Left"); layoutCall1.arguments.push(layoutCallArgument1); .. .. .. .. var zTemplatePage_Overview = pages.Page.createIn(unit); zTemplatePage_Overview.name = "zTemplatePage_Overview"; zTemplatePage_Overview.canvasWidth = 1200; zTemplatePage_Overview.canvasHeight = 600; zTemplatePage_Overview.layoutCall = layoutCall1; // Note: for this property a default value is defined. zTemplatePage_Overview.title = text13; // Note: for this property a default value is defined. zTemplatePage_Overview.popupResizable = true; gridControlBar1.defaultButton = editButton1; }       When I attempt to update project in Desktop Modeler from Team I get the following error and have to reset the project. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentNullException: Value cannot be null. Parameter name: value at Mendix.Modeler.WebUI.Forms.Widgets.FormCalls.LayoutCallArgument.set_ParameterId(LayoutParameterIdentifier value) in C:\jenkins\workspace\WebUI-Build\modeler\Mendix.Modeler.WebUI\Forms\Widgets\FormCalls\LayoutCallArgument.Generated.cs:line 45 --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index) at Mendix.Modeler.Storage.Operations.UnitContentsLoader.FillProperties(IStorageUnit containingUnit, IStorageObject obj, JObject jObject, ICachedType cachedType) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Storage\Operations\UnitContentsLoader.cs:line 71 at Mendix.Modeler.Storage.Operations.UnitContentsLoader.ConstructObjectInternal(IStorageUnit containingUnit, IStorageObject container, JObject jObject) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Storage\Operations\UnitContentsLoader.cs:line 60 at Mendix.Modeler.Storage.Operations.UnitContentsLoader.ConvertFromStorage(IStorageUnit containingUnit, IStorageObject obj, ICachedProperty prop, JToken token) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Storage\Operations\UnitContentsLoader.cs:line 136 at Mendix.Modeler.Storage.Operations.UnitContentsLoader.FillProperties(IStorageUnit containingUnit, IStorageObject obj, JObject jObject, ICachedType cachedType) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Storage\Operations\UnitContentsLoader.cs:line 90 at Mendix.Modeler.Storage.Operations.UnitContentsLoader.ConstructObjectInternal(IStorageUnit containingUnit, IStorageObject container, JObject jObject) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Storage\Operations\UnitContentsLoader.cs:line 60 at Mendix.Modeler.Storage.Operations.UnitContentsLoader.ConvertFromStorage(IStorageUnit containingUnit, IStorageObject obj, ICachedProperty prop, JToken token) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Storage\Operations\UnitContentsLoader.cs:line 136 at Mendix.Modeler.Storage.Operations.UnitContentsLoader.FillProperties(IStorageUnit containingUnit, IStorageObject obj, JObject jObject, ICachedType cachedType) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Storage\Operations\UnitContentsLoader.cs:line 94 at Mendix.Modeler.Storage.Operations.UnitContentsLoader.ConstructObjectInternal(IStorageUnit containingUnit, IStorageObject container, JObject jObject) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Storage\Operations\UnitContentsLoader.cs:line 60 at Mendix.Modeler.Storage.Operations.UnitContentsLoader.ConstructUnitFromContents(IStorageUnit container, Byte[] contents) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Storage\Operations\UnitContentsLoader.cs:line 33 at Mendix.Modeler.Storage.Operations.UnitLoader.ConstructUnit(IStorageUnit container, DbDataReader reader) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Storage\Operations\UnitLoader.cs:line 215 at Mendix.Modeler.Storage.Operations.UnitLoader.LoadChildUnits(IStorageUnit unit) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Storage\Operations\UnitLoader.cs:line 143 at Mendix.Modeler.Storage.Operations.UnitLoader.LoadChildUnits(IStorageUnit unit) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Storage\Operations\UnitLoader.cs:line 179 at Mendix.Modeler.Storage.Operations.UnitLoader.LoadChildUnits(IStorageUnit unit) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Storage\Operations\UnitLoader.cs:line 179 at Mendix.Modeler.Storage.Operations.UnitLoader.Load[T](IProgressInfo info, Dictionary`2 _knownUnits, Boolean& conversionNeeded) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Storage\Operations\UnitLoader.cs:line 48 at Mendix.Modeler.Operations.Loader30.<>c__DisplayClass0_0.<DoLoad>b__0(Database database) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Core\Operations\Loader30.cs:line 22 at Mendix.Modeler.Utility.DbConnectors.DbConnector.WithoutTransactionDo[TResult](Func`1 action) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Utility\DbConnectors\DbConnector.cs:line 64 at Mendix.Modeler.Utility.DbConnectors.SQLiteConnector.Do[TResult](String filePath, Boolean useTransaction, Func`2 action) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Utility\DbConnectors\SQLiteConnector.cs:line 58 at Mendix.Modeler.Storage.Database.Do[TResult](String filePath, Boolean useTransaction, Func`2 action) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Storage\Database.cs:line 0 at Mendix.Modeler.Operations.Loader30.DoLoad(IProgressInfo info, String filePath) in C:\jenkins\workspace\Modeler-Build\modeler\Mendix.Modeler.Core\Operations\Loader30.cs:line 18  
asked
1 answers
0

Maybe your version of model sdk is old. I've tested it now with my code and it works using the last version of model sdk and platform sdk. 

The other possibility is that you pass wrong layout template name or placeholder. So try using this: 

var layoutCallArgument1 = mendixmodelsdk_1.pages.LayoutCallArgument.create(model);
    layoutCallArgument1["__parameter"].updateWithRawValue("NavigationLayouts.Sidebar_Full_Responsive.Content");
    layoutCallArgument1.widget = groupBox1;

    var layoutCall1 = pages.LayoutCall.create(model);
    layoutCall1.layout = model.findLayoutByQualifiedName("NavigationLayouts.Sidebar_Full_Responsive");
    layoutCall1.arguments.push(layoutCallArgument1);

 

answered