Re: Save Changes - Cart Item (214 Views)
Reply
Occasional Contributor
Daniele_Rome
Posts: 5
Registered: ‎08-05-2010
Message 1 of 5 (327 Views)

Save Changes - Cart Item

Hi to All,
I Have a problem.
I added a custom fields in the table svcCartItem.
The same fields have been added in the form: svcCat.disp.item and in the form: svcCat.edit.item.
The input for the fields in svcCat.disp.item is: $Var_Name, the input for the svcCat.edit.item is: Var_Name.
I added a trigger(after Add) for the svcCartItem table the call a this script:
function my_function(record){

var myCartItem = new SCFile("svcCartItem");
var rc = myCartItem.doSelect("cartItemId=\"" + record[0] + "\"");

if(rc == RC_SUCCESS){



var Var_name1 = system.vars.$name1;
var Var_name2 = system.vars.$name2;

myCartItem.name1 = Var_name1;
myCartItem.name2 = Var_name2;

myCartItem.doUpdate();

}
}

In the svcCat.disp.item when I push "Add to Cart" the item is added to cart successfully; but if I try to edit the item by opening the form svcCat.edit.item, the changes are not made.
Can you help me figure out what to do to modify the item?

Thank you very much.

Daniele
Esteemed Contributor
michael.gregory
Posts: 230
Registered: ‎02-10-2010
Message 2 of 5 (327 Views)

Re: Save Changes - Cart Item

Hi,
I'm currently implementing a similar requirement - adding custom fields to svcCat.disp.item.

I like your approach and am going to try something similar - using triggers to update new fields in svcCartItem. I'll let you know if I get it working.
Esteemed Contributor
michael.gregory
Posts: 230
Registered: ‎02-10-2010
Message 3 of 5 (327 Views)

Re: Save Changes - Cart Item

I have this working some-what successfully.

1. Added new fields to svcCat.disp.item with input as $field1, $field2

2. Added new fields to dbdict svcCartItem: custom.field1, custom.field2

3. Add new dbdict fields to format svcCat.edit.item

4. Added new trigger on svcCartItem, before add

Trigger runs the following code directly (does not call a script library)

if (system.functions.nullsub(system.vars.$field1,null)!=null)
record.custom_field1=system.vars.$field1;

if (system.functions.nullsub(system.vars.$field2,null)!=null)
record.custom_field2=system.vars.$field2;


After adding an item to my cart the trigger runs an populates the custom fields from the variables. Click "edit item" and I can see the new field values on svcCat.edit.item.

Only issue is that modifying these new fields and clicking 'save' will not save changes to the new fields.
Occasional Visitor
ChnHydro
Posts: 2
Registered: ‎10-31-2011
Message 4 of 5 (289 Views)

Re: Save Changes - Cart Item

You can use another trigger (before udapte) to save your updates :

Displayoption svcCat.edit.item for the Save (make sure you do these modifications for all your do svcCat.edit.item on save)

$custom.field1=custom.field1 in $L.file

$custom.field2=custom.field2 in $L.file

...

 

trigger (we create a trigger on the svcCartItem table) before update

if (system.functions.nullsub(system.vars.$custom_field1,null​)!=null)

{

record

.custom_field1=system.vars.$custom_field1;

}

if (system.functions.nullsub(system.vars.$custom_field2,null​)!=null)

{

record

.custom_field2=system.vars.$custom_field2;

}

 

 

And everything is working fine

 

Frequent Advisor
abhin88
Posts: 100
Registered: ‎01-07-2013
Message 5 of 5 (214 Views)

Re: Save Changes - Cart Item

Hi michael.gregory
I am facing a similar issue now. I am trying to map fields from svcCat.disp.item to svcCat.edit.item. I indeed suceeded with the methods given here. But, now when I try to add another catalog item (same one) I see the field values already stored and display on the form. ? IS there a way to restrict this ?
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.