# Inventory service in Web sdk

**URL:** <https://community.cumulocity.com/t/inventory-service-in-web-sdk/4827>\
**Category:** Forum\
**Tags:** analytics, device-connectivity, cumulocity\
**Created:** [April 24, 2024, 7:57am UTC](https://community.cumulocity.com/t/inventory-service-in-web-sdk/4827 "2024-04-24T07:57:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rushikesh\_n](https://avatars.discourse-cdn.com/v4/letter/r/c57346/32.png) [@rushikesh\_n](https://community.cumulocity.com/u/rushikesh_n)\
**Post date:** [April 24, 2024, 7:57am UTC](https://community.cumulocity.com/t/inventory-service-in-web-sdk/4827/1 "2024-04-24T07:57:59Z")

</div>

#### _ **Product/components** used and **version/fix** level:_

c8y\_version: 1018.0.240

#### _Detailed explanation of the problem:_

I am developing an Angular application using Web sdk in which I want to update an managed object i.e I want to update the fragment value of managed object like “c8y\_Value”: true or false based on some condition  
my fragment:

```
"c8y_Value": "false",

```

```auto
clicked(event,context){
    if(event.target.checked){
      console.log("toggle switch clicked")
      console.log(context);
      // api call to be made here
        const partialUpdateObject: Partial<IManagedObject> = {
        customFragment: 'Changed data',
        name: 'Name'
        };
        
        (async () => {
        const {data, res} = await this.inventory.update(partialUpdateObject);
        })();
      
    }else{
      console.log("toggle switch unclicked");
      console.log(context)
    }
  }

```

attached the code snippet for the same, what should be there in the custom fragment?

---

<div class="post-metadata">

**Author:** ![Tristan\_Bastian](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/tristan_bastian/32/18259_2.png) [@Tristan\_Bastian](https://community.cumulocity.com/u/Tristan_Bastian)\
**Post date:** [April 24, 2024, 9:12am UTC](https://community.cumulocity.com/t/inventory-service-in-web-sdk/4827/2 "2024-04-24T09:12:59Z")

</div>

Hi @rushikesh_n,

You would need to provide the id of the managedObject you would like to update to the `update` method as well. In below sample I’m assuming that your context is having the id of the managedObject you would like to update and that the event is an Input Event coming from an checkbox input. The `c8y_Value` attribute will be updated to `true` in case that the checkbox is checked and to `false` in case it is unchecked.

```auto
  async clicked(event: InputEvent, context) {
    const eventTarget = event.target as HTMLInputElement;
    const partialUpdateObject: Partial<IManagedObject> = {
      c8y_Value: !!eventTarget.checked,
      id: context.id
    };

    const { data, res } = await this.inventory.update(partialUpdateObject);
  }

```

Regards,  
Tristan

---

<div class="post-metadata">

**Author:** ![rushikesh\_n](https://avatars.discourse-cdn.com/v4/letter/r/c57346/32.png) [@rushikesh\_n](https://community.cumulocity.com/u/rushikesh_n)\
**Post date:** [April 24, 2024, 9:39am UTC](https://community.cumulocity.com/t/inventory-service-in-web-sdk/4827/3 "2024-04-24T09:39:15Z")

</div>

Thanks @Tristan_Bastian for helping

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/system/32/31990_2.png) [@system](https://community.cumulocity.com/u/system)\
**Post date:** [October 21, 2024, 9:39am UTC](https://community.cumulocity.com/t/inventory-service-in-web-sdk/4827/4 "2024-10-21T09:39:48Z")

</div>

Closed on October 21, 2024, 9:39am UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
