Wakanda Page Prototype Custom Save - wakanda

I have 3 tables, sale, detail_sale, and item like this:
sale {id, date}
detail_sale {id, sale, item, qty}
item {id, name}
So, in wakanda how do I insert table sale and detail_sale in one page with page prototype?
That I read in Wakanda Documentation, I insert sale table fist and then insert detail_sale. Can I insert sale and detail_sale in one time?

the save method is asynchronous so you can not know when it's done,
So the best thing is to make nested calls, so in the onSuccess callback (of sale) you can call the save of 'detail_sale'

Related

Choose the first non-null field for each record in ServiceNow

How to create a view in ServiceNow that combines multiple columns (same data type) into one by picking the first non-null value? Note that it should not actually modify the underlying data.
After a search of the documentation I thought I had an answer with function fields, but GlideFunction doesn't seem to have nvl/coalesce as a function. The functionality called coalesce in ServiceNow seems to relate to importing/permanently modifying data only.
An example would be if you have employee and department, both of which have a location field. Show the employee's location unless it is null, otherwise show the employee's department's location.
In standard SQL, I would do it like this:
CREATE VIEW my_view AS (
SELECT COALESCE(employee.location,department.location) AS location
FROM employee JOIN department
ON employee.department_id = department.department_id
);
You have not mentioned how you are going to query this view. SNOW does not give us control over selection while designing views like the standard SQL.
Use GlideRecord to conditionally select the columns based on nullability.

session for multiple devices

I am trying to build an ecommerce site.for the cart functionality I want to alive my cart for multiple devices.For example if I create an account and add some product to my cart using my mobile browser,after that if I use the same account to my pc browser I should see the cart with those product I added using my mobile browser.I donno how to do that or what's the method,can you please help me??
My Preferred Approach
In order to do this, you'll want to create or leverage some sort of profile data source. For example, if you're using a database, you likely have a Users table with a record for each customer. I'd suggest adding a new related table that might look something like this to begin with...
Potential Table Name: UserData
UserID (FK)
DataName (string)
DataValue (string)
So, after logging in, the visitor might add something to their cart. When this happens, you'd have a CartID to work with and then add a record to that table with their UserID and it might look like this in T-SQL.
INSERT INTO [dbo].[UserData] ([UserID],[DataName],[DataValue])
VALUES (12345, 'CartID', 'd501e3de-350c-4c20-92c8-8e71445e1774');
Now, when they log in again anywhere, you'd just query for that UserID to find out if they have a cart pending. If they do, load it up. Just remember to clear that value on checkout.
The beauty of this solution is that you can repurpose it for all kinds of other things.
An Alternative Approach
Just query your Cart table, assuming in your solution you're storing carts before checkout is completed. Find the most recent instance of a cart matching their UserID that hasn't been completed.

Any way to intercept an error message and make more user friendly?

I have looked for an answer here among other places but havent quite been able to find what I need to know.
I have 3 tables, Order_Details, Products_Ordered and Product_Details. The first two are being used in a master detail form to show the order and the items ordered together. The Products_Ordered table has a composite primary key made from two foreign keys, the first being the primary key from the Order_Details table, and the second being the primary key from the Product_Details table. Together they ensure that a type of product can only be added to an order once. If someone wants to order more than one product then the quantity field in the record can be altered to reflect this. All that seems fine so far.
My issue is that when adding products to the order in the master detail form i have used a drop down list of values to select the product to add to the order. the display value for this is the product name and the return value for it is the primary key for the product from the Product_Details table.
I like this because its easier for the user to simply select the product and add a quantity of it to the table. And it works fine for both insert and update operations apart from one situation.
If the user selects the same product in to rows then submits the table the database then tries to add the product to the order twice, throwing a "ORA-00001: unique constraint violated." error. Obviously this is because of the product ID being used in the primary key of the table.
I don't want to allow the user to add two records to the table like that, rather id like to force them to alter the quantity field accordingly. The error message that comes up isn't very user friendly so my question is how can I detect this error and display a more user friendly one instead telling them to alter the quantity field instead?
*If this isn't possible then is there a way that I can hide any already selected products from the dropdown list of values in the following table rows? I haven't looked into this too much because surely it would get complicated when the user tries to add more rows than products available in the dropdown and there are no more products values to show?
I am quite new to this so please be nice. Any help is greatly appreciated :D
Here is a link where all is nicely described:
https://docs.oracle.com/cd/A97630_01/appdev.920/a96624/07_errs.htm
Section
Predefined PL/SQL Exceptions
in combination with:
Defining Your Own PL/SQL Exceptions
and
Defining Your Own Error Messages: Procedure RAISE_APPLICATION_ERROR
Hope it helps...

Get order_id before submiting order in Magento

I have added a custom field in checkout page at shipping method step in magento. I am able to insert data from this field to my custom table mg_cake_message(msg_id,customer_id,cake_msg). I need another attribute (order_id) to show data for respective orders in admin panel. How can i get order_id before submitting an order?
I have searched in google and some of people suggest to use quote_id instead of order_id. Is quote_id is same as order_id ?
If it's not possible to get order_id before submiting order then how can the two previous step(Billing Information, Shipping Information) is managed?
Please make me a response .....
A quote in Magento is basically an order that hasn't been placed yet. It contains product items (shopping cart), addresses and payment/shipping methods. It is created as soon as you add an item to cart and Magento creates a sales/quote object.. During checkout, billing and shipping data is added to the quote. Finally, when the user clicks place order, the quote object is converted to an order sales/order object.

magento get value from sales_flat_order_item table for print in invoice page

i am using magento 1.7.0.2.In sales_flat_order_item table i have created a field "real_original_price" where i storing product's original price(in case of special price).Price is storing properly.Now problem is how do i show the real_original_price field's data in my invoice page .Actually my target is showing user discounted amount in invoice that is (original price - sell price). How do i achieve this.any idea
https://www.sonassi.com/knowledge-base/magento-kb/display-attributes-on-invoice-or-packing-slip-in-magento/
You can write an observer on order save or invoice save event. In the observer you can fetch the original price from catalog_product_entity and update in sales_flat_order.

Resources