How to Save multiple ids in an Entity

Hi All,

I am creating a mini application where my loggedin customer can add product into cart. My concern is

I have Cart entity which contains ProductId & CustomerId but I don't understand how to pass ProductId & CustomerId for creating new Customer

And i am passing ProductId from TableRecord when user clicks i am expecting "Feedback Message" which displays but how to save it.


I found how to read logged in user's if by using -> GetUser(GetUserId()).User.Id


please guide me here


thanks


Shailendra Phadke wrote:

Hi All,

I am creating a mini application where my loggedin customer can add product into cart. My concern is

I have Cart entity which contains ProductId & CustomerId but I don't understand how to pass ProductId & CustomerId for creating new Customer

And i am passing ProductId from TableRecord when user clicks i am expecting "Feedback Message" which displays but how to save it.


I found how to read logged in user's if by using -> GetUser(GetUserId()).User.Id


please guide me here


thanks


Hello Phadke,

Can you please re-frame  the question.

If possible attach any reference (like screenshot or oml file).


Thanks,

Govardhan.


Govardhan Reddy wrote:

Shailendra Phadke wrote:

Hi All,

I am creating a mini application where my loggedin customer can add product into cart. My concern is

I have Cart entity which contains ProductId & CustomerId but I don't understand how to pass ProductId & CustomerId for creating new Customer

And i am passing ProductId from TableRecord when user clicks i am expecting "Feedback Message" which displays but how to save it.


I found how to read logged in user's if by using -> GetUser(GetUserId()).User.Id


please guide me here


thanks


Hello Phadke,

Can you please re-frame  the question.

If possible attach any reference (like screenshot or oml file).


Thanks,

Govardhan.


When User Clicks on the Make Order Button Product Id and LoggedIn User Id to be saved in Cart Table

Cart table has below structure

Id

ProductId

CustomerId


I want to store ProductId and CustomerId so that i can understand who bought which product 














Hello Shailendra Phadke


If i understood you question correctly then this is the answer

Before creating the cart you need to fetch ProductID and CustomerID , then you can pass these values while creating the Cart

I hope this helps you , if you still need info please let me know

cheers

Srinivas Singadi wrote:

Hello Shailendra Phadke


If i understood you question correctly then this is the answer

Before creating the cart you need to fetch ProductID and CustomerID , then you can pass these values while creating the Cart

I hope this helps you , if you still need info please let me know

cheers


Yes it is right. But again how do I save this values using CreateCart Action? Because it only contains Id parameter or has it any other way to save these values?



Hello again,

Ok , so you are passing Product Id Form table record as you said in the above comment , 

and about the CustomerId, you need to pass Registered UserID 

For geting UserID you can use built in function its like as shown below:

SyntaxEditor Code Snippet

GetUserId()


Note: if you want to get your cart details then you need join these three tables , by joining you fetch all the attributes you want


i hope this helps you 

Srinivas Singadi wrote:

Hello again,

Ok , so you are passing Product Id Form table record as you said in the above comment , 

and about the CustomerId, you need to pass Registered UserID 

For geting UserID you can use built in function its like as shown below:

SyntaxEditor Code Snippet

GetUserId()


Note: if you want to get your cart details then you need join these three tables , by joining you fetch all the attributes you want


i hope this helps you 

Shrinivas,



I got this. But i don't understand how to save it in Cart table?


To save you use CreatCart or CreateorUpdateCart these functions saves your record right? 

When you click your table record productId you can create onclick sever action inside this server action you pass input parameter as productId and here in this action you use CreateorUpdateCart in this way you save your cart.

If this is not you want then may be am not understanding ur question 

Srinivas Singadi wrote:

To save you use CreatCart or CreateorUpdateCart these functions saves your record right? 

When you click your table record productId you can create onclick sever action inside this server action you pass input parameter as productId and here in this action you use CreateorUpdateCart in this way you save your cart.

If this is not you want then may be am not understanding ur question 

Friend 

you are right. 

But again what should  I pass to CreateOrUpdateCart's Source property?


In Feedback Message I can able to display product id and customer id.


Solution

ok 

Create local variable called "NewCart" of data type Cart , 

then above flow of  createorUpdate you can assign you productId and customerId to this local variable 

In createorUpdateCart you can pass this local variable as source

In the assignment can assign something like this 

Solution

Srinivas Singadi wrote:

ok 

Create local variable called "NewCart" of data type Cart , 

then above flow of  createorUpdate you can assign you productId and customerId to this local variable 

In createorUpdateCart you can pass this local variable as source

In the assignment can assign something like this 


Very thanks Shrinivas.

It is working very fine for me now.  Actually, I didn't know how to pass multiple values to local variable like this. It is  really fantastic feature. Your above image clear my doubt. 

Thanks once again.