I'm pretty new to writing triggers so please bear with me.
I have two objects (Opportunity Line Item) and (NoticeOfSaleProduct_c). I want to update 2 fields (commision) and (percentage) which are common in both the objects. So if I update these two fields while creating a record in (Opportunity Line Item) object it should populate in (NoticeOfSaleProduct_c) object as well.
Please help
Related
I am new in Salesforce and I need to add a new value in a picklist. Once added, I save, but when a I need to create a new record of the object within which there is the picklist, the new value is not rendered. Someone can explain me why?? Thanks
I tried by adding the new value by editing the picklist.
Does your object have "record types"? Like "ok, all accounts go to 1 database table but hospitals/factories/marketing agencies need different fields visible, different rules around what is required and even if they use same picklists - values on the picklists may differ". When you were adding that new picklist value it probably asked you to which (if any) record types you want it added...
Firstly, you should make sure the picklist value is active. Then make sure that the user profile viewing the page has visibility to that record type. this can be checked under Profile > Object settings > Work Order (or object that applies). After checking make sure that picklist field value was added to the appropriate record type.Please give feedback if u managed to get this done.
Breeze & Angular & MV*
I get an invoice object and expand it's necessary properties: Customer, Details, etc.
To access detail properties is easy, invoice.detail[n].property. And saving changes to existing properties (1 - n) is also easy. In my UI, I simply loop through my object vm.invoice.details to get & display all existing details, bind them to inputs, edit at will, call saveChanges(), done!
(keep in mind, in this UI, I need to complete the following too....)
Now, I have blank inputs for a new detail I need to insert.
However, I need to insert a new detail into the existing array of invoice details.
For example: invoice #5 has 3 details (detail[0], detail[1], detail[2]). I need to insert into this existing invoice, detail[3], and call saveChanges()
I've tried to call the manger.createEntity('invoice') but it complains about FK constraints. I know you can pass values as a second argument in createEntity('obj', newvalues)...but is that the correct and only method?
Seems like this should all be much easier but, well, I am at a loss so, please help where you can. TIA!
Take a look at the DocCode sample which has tests for all kinds of scenarios including this one.
Perhaps the following provides the insight you're looking for:
function addNewDetail() {
var newDetail = manager.createEntity('Detail', {
invoice: vm.currentInvoice,
... other initial values
});
// the newDetail will show up automatically if the view is bound to vm.details
}
Notice that I'm initializing the parent invoice navigation property. Alternatively, I could just set the Detail entity's FK property inside the initializer:
...
invoiceId: vm.currentInvoice.id,
...
Either way, Breeze will add the new detail to the details collection of the currentInvoice.
Your question spoke in terms of inserting the new Detail. There is no need to insert the new Detail manually and you can't manage the sort order of the vm.currentInvoice.details property any way.
Breeze has no notion of sort order for collection navigation properties.
If you need to display the details in a particular order you could add a sorting filter to your angular binding to vm.currentInvoice.details.
Make sure you have correct EntityName, because sometimes creating entity is a not as simple as it seems.Before working with entities see
http://www.getbreezenow.com/documentation/creating-entities
I will suggest you to look ur metadata file, go to last line of your file, you can see the field named "entitySet"
"entitySet":{"name":"Entity_Name","entityType":"Self.Entity_Name"}
check the entityName here i took as "Entity_Name" and then try to create the entity and use this name
manger.createEntity('Entity_Name');
I have a database of finance info and i want to check that supplied totals 'add up'. I have added fields to the database for the check data and am using data binding via the Entity Framework. How do i populate these 'check' fields while the user is adding data to the record?
Eg The form contains SubtotalA, SubtotalB and TotalAB textboxes. The database has these fields plus CheckTotalAB. The user keys in SubtotalA, SubtotalB and TotalAB from a hard copy form. I want to populate CheckTotalAB with the sum of SubtotalA and SubtotalB to compare against the provided TotalAB.
I first tried getting the data from the textboxes. Unfortunately txtSubtotalA.Value doesn't exist.
I then thought I'd have to go to the entity itself. Unfortunately I don't know how to access the current record/entity being entered and if I did, how would I access the value of fields that haven't been saved yet.
Can someone point me in the right direction?
tia
mcalex
Accessing the entity was the answer. This was accomplished through use of an entity property in the datacontext that i set to equal a class member i added to my form class.
After that getting to the entity's fields including my calculated fields was just a case of getting/setting the member's properties.
sorry for the silly question but this is my first approach with WPF and Entity Framework.
Let's explain my scenario...
I have a master class (Customers) and a detail class (Orders), both in my EF context.
I load my master class with a LINQ-to-EF query (including Orders) and put the IEnumerable result set in an ObservableCollection, that is used as source to a ListBox.
Then I have a DataGrid where I load the orders.
Now, because the master items are in an ObservableCollection, I am able to add, delete and update an item and that automatically reflects to my ListBox.
The problem is when I need to add an Order to a Customer.
Is there a way to update only an item in the ObservableCollection without re-load all the items from the context?
This is my code (simplified)
// Loading Customers
EntitiesContext context = new EntitiesContext();
IEnumerable<Customer> customers = from c in context.Customer.Include("Orders")
select c;
ObservableCollection<Customer> oc = new ObservableCollection<Customer>(customers);
// Binding ListBox
listCustomers.ItemsSource = oc;
...
// Retrieving a Customer (1st for instance...)
Customer c = (listCustomers.Items[0] as Customer);
Order o = new Order {Customer = c.ID, Item = "xxx"};
context.AddToOrders(o);
// How can I update the ObservableCollection?
Thanks in advance,
Manuel
Part of the problem may be manually setting the association (Foreign Key) property on the Order. When adding an object to a parent object in EF, you really just do something like the following:
Order o = new Order {Item="xxx"};
c.Orders.Add(o);
context.AddToOrders(o);
In this way you create the object, add it to the collection on the local side that you want it (behind the scenes EF tracks it's creation and remembers to give it a Key and Association Key) and it adds it to the contexts over-all Orders collection.
Be sure to call save changes when you are done with that operation and it will create the FK value and save it all to the database.
Also, of note: If you have more elaborate Object Hierarchies thyan just the two classes, (which is likely) you might look into LazyLoading if you don't want to have really goofy include statements hardwired into your code. This will retrieve needed data only when it is actually requested and will keep your LINQ statements a lot more succinct.
quite an explanation here, hope someone has the patience to read it through
I'm building an application in Flex 4 that handles an ordering system. I have a small mySql database and I've written a few services in php to handle the database.
Basically the logic goes like this:
I have tables for customers, products, productGroups, orders, and orderContent
I have no problem with the CRUD management of the products, orders and customers, it is the order submission that the customer will fill in that is giving me headaches:
What I want is to display the products in dataGrids, ordered by group, which will be populated with Flex datamanagement via the php-services, and that per se is no problem. But I also want an extra column in the datagrid that the user can fill in with the amount he wishes to order of that product. This column would in theory then bind to the db table "orderContent" via the php services.
The problem is that you would need to create a new order in the database first that the data could bind to (orderContent is linked to an order in the db).
I do not want to create a new order every time a user enters the page to look at the products, rather I would like to create the order when a button is pressed and then take everything from the datagrids on the page and submit it into the database.
My idea has been to create a separate one-column datagrid, line it up next to the datagrid that contains the products and in that datagrid the user would be able to enter the amount of that product he'd like to order.
I've created a valueObject that contains the data I would need for an order:
Code:
package valueObjects
{
public class OrderAmount
{
public var productId:int;
public var productAmount:int;
public var productPrice:Number;
public function orderAmount()
{
}
}
}
My idea was to use a service to get all products from a certain group, populate an ArrayCollection with the data, then transfer each object in that ArrayCollection to an instance of the Value Object above, add the value object to another ArrayCollection that would the be used as a dataProvider for the one-column datagrid (I would only display amount which would be set to zero at first, but use the other data upon transfering it to the db)
I've tried to use the results from the automatically generated serviceResults that retrieve the products for the datagrid and put in a resultHandler that transfers the valueobjects, however this does not seem to work.
Basically my question is this: Am I approaching this thing completely wrong, or is there a way I can get it to work the way I planned?
Would I need to create a completely new service request to get the product id:s, and price to populate the one-column datagrid.
I'll post some code if that would help.
Thank you if you read this far.
Solved it by creating a Value Object class to hold all the info needed for each row in the grid and from the php service that returned all products in a group, I looped through the result and transfered the data needed into my Value Object.
I then added each Value Object into an ArrayCollection and made that the dataProvider for the dataGrid.
No need to use two grids. I forgot how logic things get when you think of datagrid data just as an ArrayCollection and forget the visual presentation of it on screen.
Put in a few itemRenderers and the whole thing is beautiful!