Integrated Application Platform › Forums › General › Updating records in a database
- This topic has 5 replies, 2 voices, and was last updated 10 years, 8 months ago by
Anonymous.
-
AuthorPosts
-
September 26, 2012 at 2:34 pm #738
Anonymous
InactiveHello. I have a new project going on. I need to update the prices on my customer database. I am trying to use QueryApply but am having trouble. Im sure its a simple problem but Im stuck. Here is the code:
function()
{
QueryApply(‘inv_customer’)
{ |x|
x.cb_price = .ncb_price
x.Update()
}
}Controller
{
Title: ‘Wagram Paper Stock Customer Price Adjustment’
Xmin: 800
Ymin: 500Controls:
(Vert
(Skip)
(Horz (Skip 300)
(Static, “Customer Price Addjustment” font: (name: Arial size: 30)))
(Skip)
(Skip)
(Horz (Skip 150)
(ncb_price)
(Skip 10)
(Static, ‘Official Board Market’))
(Horz (Skip 150)
(now_price)
(Skip 10)
(Static, ‘Official Board Market’))
(Horz (Skip 150)
(ntube_price))
(Horz (Skip 150)
(nnews_price))
(Horz (Skip 150)
(nmixed_paper_price))
(Horz (Skip 150)
(nplastic_bot_price))
(Horz (Skip 150)
(nplastic_film_price))
(Horz (Skip 150)
(naluminum_price))
(Horz (Skip 150)
(nrecyclables_price))
(Horz (Skip 150)
(nsteel_price))
(Skip)
(Skip)
(Horz (Skip 300) (Button, “OK”) (Button, “Cancel”)))
On_OK()
{
Alert(‘You are about to update all customer prices’ Title: ‘ALERT’)
Inv_price_update()
}
}I need to update all the prices that are entered but started with just the ncb_price to figure it out.
Thanks for your help
BennySeptember 26, 2012 at 2:53 pm #943j_ferguson
ModeratorHi,
Are you trying to update your database records based on the prices that are entered on the screen? To do that you’ll need to get the data from the screen and pass it to your function that does the QueryApply. Try using a RecordControl at the top level of your Controller controls. Then in your On_Ok method you should be able to reference the RecordControl’s data (which should include all the price amounts entered on the screen) by using .Data.Get()
Once you have the screen data you can pass it to your Inv_price_update function. Assuming your parameter is called data, the line to set the cb_price field would then be:
x.cb_price = data.ncb_price
I hope I am understanding what you are trying to do.
Jeff Ferguson
September 26, 2012 at 3:00 pm #944j_ferguson
ModeratorI also forgot to mention that you will need to pass true in the update argument to QueryApply. By default it uses a readonly transaction:
QueryApply(‘inv_customer’, update:)
…Jeff Ferguson
September 26, 2012 at 6:16 pm #945Anonymous
InactiveThanks for your reply, but Im still not doing something right. I get the following error: ‘uninitialized member: #Class56_data’ when the function is called. I am reposting the new code
//Inv_price_update
function(data)
{
QueryApply(‘inv_customer’, update:)
{ |x|
x.cb_price = data.ncb_price
x.Update()
}
}//Account Entry
Controller
{
Title: ‘Wagram Paper Stock Customer Price Adjustment’
Xmin: 800
Ymin: 500Controls:
(Record
(Vert
(Skip)
(Horz (Skip 300)
(Static, “Customer Price Addjustment” font: (name: Arial size: 30)))
(Skip)
(Skip)
(Horz (Skip 150)
(ncb_price)
(Skip 10)
(Static, ‘Official Board Market’))
(Horz (Skip 150)
(now_price)
(Skip 10)
(Static, ‘Official Board Market’))
(Horz (Skip 150)
(ntube_price))
(Horz (Skip 150)
(nnews_price))
(Horz (Skip 150)
(nmixed_paper_price))
(Horz (Skip 150)
(nplastic_bot_price))
(Horz (Skip 150)
(nplastic_film_price))
(Horz (Skip 150)
(naluminum_price))
(Horz (Skip 150)
(nrecyclables_price))
(Horz (Skip 150)
(nsteel_price))
(Skip)
(Skip)
(Horz (Skip 300) (Button, “OK”) (Button, “Cancel”))
)
)
On_OK()
{
.Data.Get()
Alert(‘You are about to update all customer prices’ Title: ‘ALERT’)
Inv_price_update(.data)
}
}Thanks again
September 26, 2012 at 9:51 pm #946j_ferguson
ModeratorYou need to save the data in a local variable and pass that to your function something like this:
On_OK()
{
data = .Data.Get()
Alert(‘You are about to update all customer prices’ Title: ‘ALERT’)
Inv_price_update(data)
}Jeff Ferguson
September 27, 2012 at 6:39 pm #947Anonymous
InactiveThanks for your assistance again. It is great how quickly you provide support here. It makes learning your program so much better.
-
AuthorPosts
- You must be logged in to reply to this topic.