I am trying to insert some records into a BusComp once an applet that's using a different Buscomp has finished loaded. Below is my code
var boContact = this.BusObject("Contact");
var bcContact = boContact.GetBusComp("Contact");
var newBC = boContact.GetBusComp("New BC");
with (newBC) {
this.SetViewMode(AllView);
this.ActivateField("Test Field");
ClearToQuery();
NewRecord(NewAfter);
this.SetFieldValue("Test Field","0010000005");
this.WriteRecord();
}
Currently this code is giving me this error 'This operation is not available for read only field 'Test Field'.(SBL-DAT-00402) '. I have checked and confirmed that the said field or any other fields in the BusComp and the table are not set to read-only.
Please share your thoughts with me, thank you so much !
Related
How do I get the field type of a field in Google App Maker?
I have tried to find it via:
app.models.MODEL_NAME.fields.date
but there isn't a property type for a field.
So the question is how can I find the type of a field via Javascript?
Many thanks
Interesting question. Here is how I do it; Suppose I want to know what are all the field types of a model. I use this:
var allFields = app.models.MODEL_NAME.fields._values;
for( var f=0; f<allFields.length; f++) {
var field = allFields[f];
var fieldType = field.__gwt_instance.b.B.j;
console.log(fieldType);
}
So, in summary, all you have to do is get the field:
var field = app.models.MODEL_NAME.fields.DESIRED_FIELD
Then you just get the type like this:
var fieldType = field.__gwt_instance.b.B.j;
As I say, this works for me. I hope this works for you too!
There is also a less cryptic attribute that will give you the field type (although it only works in server scripts):
app.metadata.models.MODEL_NAME.fields.DESIRED_FIELD.type;
I have a the following code to fill data for my Asp.net gridview. I used the same code as below in other asp.net page to load data to gridview. All other pages are fine with the code and successfully display gridview with data. But in one page, to display product list of customer purchasing, it display error.
This is my code.
using (DataContext.DBEntities ctx = new DataContext.DBEntities())
{
List<DataContext.vwClientAndProduct> product = new List<DataContext.vwClientAndProduct>();
product = ctx.SP_ClientAndProduct_Select().ToList<DataContext.vwClientAndProduct>();
gvList.DataSource = product.ToList();
gvList.DataBind();
}
I traced the code of the error page, it successfully passed gvList.DataBind() method. But when I continue F5, error message displayed in my product.aspx page. The error starts with 'Data binding directly to a store query (DbSet, DbQuery, DbSqlQuery, DbRawSqlQuery) is not supported....'
Each of the following is not worked too.
var product = (from row in ctx.SP_ClientAndProduct_Select()
select row).ToList();
//var product = from row in ctx.SP_ClientAndProduct_Select()
select row;
//var product = ctx.SP_ClientAndProduct_Select().ToList();
gvList.DataSource = product.ToList();
gvList.DataBind();
The other page is working well with the following.
using (DataContext.DBEntities ctx = new DataContext.DBEntities ())
{
var product = ctx.SP_Product_Select().ToList()
gvList.DataSource = product.ToList();
gvList.DataBind();
}
I don't know why this is not working although the code is same.
Please help.
Thanks
It worked !
I created a new aspx page and copy all code from error page to new page.
When new page load, the gridview displays with data.
Very Strange !
Thanks.
I promise I have read through the Query information page, but obviously I am missing/misunderstanding something.
I have a Table that has the statuses for multiple departments (the fields are Strings). When a user loads that table I want App Maker to hide jobs that have been finished.
The way we categorize a job as finishes is when:
The Inventory Status = Complete and when the The Delivery Status = Delivered.
Both these conditions need to be met.
Example:
Inventory (Complete) + Delivery (Delivered) = hide
Inventory (In Progress) + Delivery (Delivered) = don't hide
Inventory (Complete) + Delivery (Scheduled) = don't hide
I tried the following, however it hides all the example listed above, not just the first one.
var datasource = app.datasources.SystemOrders;
var inventory = ['Complete'];
var delivery = ['Delivered'];
datasource.query.filters.InventoryStatus._notIn = inventory;
datasource.query.filters.DeliveryStatus._notIn = delivery;
datasource.load();
I have also tried this:
var datasource = app.datasources.SystemOrders;
datasource.query.filters.InventoryStatus._notIn = 'Complete';
datasource.query.filters.DeliveryStatus._notIn = 'Delivered';
datasource.load();
But I get this error:
Type mismatch: Cannot set type String for property _notIn. Type List is expected. at SystemOrders.ToolBar.Button2.onClick:2:46
Any help would be greatly appreciated.
Filters are using AND operator. Please consider switching the Datasource Query Builder and applying the following query:
"InventoryStatus != :CompleteStatus OR DeliveryStatus != :DeliveredStatus"
Set CompleteStatus variable to Complete
Set DeliveredStatus variable to Delivered
Explanation:
Filter you want to apply is "NOT(InventoryStatus = Complete AND DeliveryStatus = Delivered)" which is equivalent to "InventoryStatus != Complete OR DeliveryStatus != Delivered".
Vasyl answer my question perfectly, but I wanted to add a few details in case anyone needs to do the same thing and aren't familiar with using the Datasource Query Builder.
All I did was click the Database I was using and then clicked the Datasources section at the top.
I clicked Add Datasource, named it a new name and pasted Vasyl's code into the Query Builder Expression box.
Two new boxes appear below it allowing me to enter the desired statuses that I wanted to filter out.
Lastly I went back to my Table and changed its datasource to my newly created datasource.
Since you are changing your datasource, if you have any extra code on there it may need to be updated to point to the new datasource.
Example:
I had some buttons that would filter entries for the various departments.
So this:
widget.datasource.query.clearFilters();
var datasource = app.datasources.SystemOrders;
var statuses = ['Complete'];
datasource.query.filters.WarehouseStatus._notIn = statuses;
datasource.load();
had to change to this:
widget.datasource.query.clearFilters();
var datasource = app.datasources.SystemOrders_HideComplete;
var statuses = ['Complete'];
datasource.query.filters.WarehouseStatus._notIn = statuses;
datasource.load();
You can use multiple run and then concatenate their results something like following
/**
* Retrieves records for ActionItems datasource.
* #param {RecordQuery} query - query object of the datasource;
* #return {Array<ActionItems>} user's rating as an array.
*/
function getActionItemsForUser_(query) {
var userRoles = app.getActiveUserRoles();
query.filters.Owner._contains = Session.getActiveUser().getEmail();
var ownerRecords = query.run();
query.clearFilters();
query.filters.AddedBy._contains = Session.getActiveUser().getEmail();
var addedByRecords = query.run();
return addedByRecords.concat(ownerRecords);
}
I have fetched records from database using this query which works fine.
var SelectEmpInfo = "SELECT * FROM emp_info WHERE emp_id ='"+empID+"'";
var SelectedEmpInfo = db.QuerySingle(SelectEmpInfo);
After that I want to update this record by applying the snap of code
if(SelectedEmpInfo != null)
{
status = SelectedEmpInfo.status;
}
if(IsPost)
{
var updateStatus = "UPDATE emp_info SET status='"+status+"' WHERE emp_id='"+empID+"'";
db.Execute(updateStatus);
<h1>Successfully Updated</h1>
}
If I remove the query from if block and put outside it than it works when page gets loaded but I don't want to do so.
The reason to place this code inside an if is that, query should only perform when button is pressed.
Please someone help me out here.
Kind regard
Radhesham
Thanks everyone for your time and concerns.
It was actually SQL injection problem and i found the answer of it here at mikes site
http://www.mikesdotnetting.com/article/113/preventing-sql-injection-in-asp-net
I am using ASP.NET MVC2 in Visual Studio 2008. I believe the SQL Server is 2005.
I have two tables: EquipmentInventory and EquipmentRequested
EquipmentInventory has a primary key
of sCode
EquipmentRequested has a
foreign key called sCode based upon
sCode in EquipmentInventory.
I am trying the following code (lots of non-relevent code removed):
try
{
EChODatabaseConnection myDB = new EChODatabaseConnection();
//this section of code works fine. The data shows up in the database as expected
foreach (var equip in oldData.RequestList)
{
if (equip.iCount > 0)
{
dbEquipmentInventory dumbEquip = new dbEquipmentInventory();
dumbEquip.sCode = equip.sCodePrefix + newRequest.iRequestID + oldData.sRequestor;
myDB.AddTodbEquipmentInventorySet(dumbEquip);
}
}
myDB.SaveChanges(); //save this out immediately so we can add in new requests
//this code runs fine
foreach (var equip in oldData.RequestList)
{
if (equip.iCount > 0)
{
dbEquipmentRequested reqEquip = new dbEquipmentRequested();
reqEquip.sCode = equip.sCodePrefix + newRequest.iRequestID + oldData.sRequestor;
myDB.AddTodbEquipmentRequestedSet(reqEquip);
}
}
//but when I try to save the above result, I get an error
myDB.SaveChanges();
oldData is passed into the function. newRequest is the result of adding to a "non-related" table. newRequest.iRequestID does have a value.
In looking at the reqEquip is the watch window, I do notice that EquipInventory is null.
The error message I receive is:
"Entities in 'EChODatabaseConnection.dbEquipmentRequestedSet' participate in the 'FK_EquipmentRequested_EquipmentInventory_sCode' relationship. 0 related 'EquipmentInventory' were found. 1 'EquipmentInventory' is expected."
Obviously I'm doing something wrong but thus far, I can not seem to find where I am having a problem.
Anyone have some hints on how to properly insert a record into a table that has a foreign key reference?
UPDATE:
I am using the Data Entity Framework.
UPDATE:
Thanks to Rob's answer, I was able to figure out my error.
As Rob mentioned, I needed to set my reference for the foreign key.
My coding result looks like:
foreach (var equip in oldData.RequestList)
{
if (equip.iCount > 0)
{
dbEquipmentInventory dumbEquip = new dbEquipmentInventory();
dumbEquip.sCode = equip.sCodePrefix + newRequest.iRequestID + oldData.sRequestor;
myDB.AddTodbEquipmentInventorySet(dumbEquip);
//add in our actual request items
dbEquipmentRequested reqEquip = new dbEquipmentRequested();
reqEquip.EquipmentInventory = dumbEquip;
myDB.AddTodbEquipmentRequestedSet(reqEquip);
}
}
myDB.SaveChanges();
Does anyone see a better method for doing this?
What are you using as an ORM? I believe that regardless of which one you're using, you could use the foreign key handling of most ORMs to handle this for you. For example, you make a new dumbEquip, don't do the immediate save. Do your dbEquipmentRequested reqEquip = new dbEquipmentRequested(); and add the data to it and then say dumbEquip.dbEquipmentRequested.Add(reqEquip). Then save the record and the ORM should save the records in the correct order required for the FK and even enter the FK ID into the reqEquip record.