# context.saveObject method

**URL:** <https://developer.sailpoint.com/discuss/t/context-saveobject-method/20929>\
**Category:** IIQ Discussion and Questions\
**Tags:** workflows, access-requests, identityiq, apis\
**Created:** [November 15, 2023, 9:42am UTC](https://developer.sailpoint.com/discuss/t/context-saveobject-method/20929 "2023-11-15T09:42:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sreeram](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/sreeram/32/25311_2.png) [@sreeram](https://developer.sailpoint.com/discuss/u/sreeram)\
**Post date:** [November 15, 2023, 9:42am UTC](https://developer.sailpoint.com/discuss/t/context-saveobject-method/20929/1 "2023-11-15T09:42:06Z")

</div>

### Which IIQ version are you inquiring about?

Version 8.X

### Is this question regarding a custom connector? If so, please share relevant details below.

No, this question is not regarding a custom connector.

### Please share any other relevant files that may be required (for example, logs).

[Approval Assignment Rule .txt](https://developer.sailpoint.com/discuss/uploads/short-url/l4kD39j53zeYbVlT9Jp5AsnfHzp.txt) (8.32 KB)

### Share all details related to your problem, including any error messages you may have received.

Hi all,

I am new to rule development and I have a question on the saveObject method. Can the saveObject method be used on approvalItems, approvalSets, and workItems?

I tried using the method on approvalItem it threw a method invocation error

BeanShell script error: bsh.EvalError: Sourced file: inline evaluation of: `import sailpoint.object.*; import sailpoint.object.Workflow; import sailpoint. . . . '' : Error in method invocation: Method saveObject(sailpoint.object.ApprovalItem) not found in class'sailpoint.server.InternalContext' : at Line: 117 : in file: inline evaluation of: `import sailpoint.object.\*; import sailpoint.object.Workflow; import sailpoint. . . . ‘’ : context .saveObject (aItem)

I have attached the rule that threw the error. as a txt file. Could anyone please help ?

---

<div class="post-metadata">

**Author:** ![iamnithesh](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/iamnithesh/32/42445_2.png) [@iamnithesh](https://developer.sailpoint.com/discuss/u/iamnithesh)\
**Post date:** [November 15, 2023, 11:51am UTC](https://developer.sailpoint.com/discuss/t/context-saveobject-method/20929/2 "2023-11-15T11:51:32Z")

</div>

If I remember right, `context.saveObject` can be used for high level objects like Identity, Application, … only

---

<div class="post-metadata">

**Author:** ![Remold](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/remold/32/3275_2.png) [@Remold](https://developer.sailpoint.com/discuss/u/Remold)\
**Post date:** [November 15, 2023, 12:09pm UTC](https://developer.sailpoint.com/discuss/t/context-saveobject-method/20929/3 "2023-11-15T12:09:28Z")

</div>

From the javadoc:

```auto
void saveObject(SailPointObject obj)
         throws GeneralException

```

_Save an object in the persistent store._

It can save any object which extends SailPointObject.

ApprovalItem and ApprovalSet are not extending SailPointObject, therefore it cannot be saved using saveObject.  
Workitem does extend SailPointObject and can be saved.

The javadoc can be found at each installation (and should be removed in production environments) via https:///identityiq/doc/javadoc/index.html

When saving an object, be sure the transaction is committed as well, otherwise it will not be saved in the database.

```auto
      context.saveObject(object);
      context.commitTransaction();

```

– Remold

---

<div class="post-metadata">

**Author:** ![iamksatish](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/iamksatish/32/26217_2.png) [@iamksatish](https://developer.sailpoint.com/discuss/u/iamksatish)\
**Post date:** [November 15, 2023, 1:06pm UTC](https://developer.sailpoint.com/discuss/t/context-saveobject-method/20929/4 "2023-11-15T13:06:46Z")

</div>

@sreeram  
As @iamnithesh and @Remold mentioned you cannot save Approval Item object but you can set the state of the item within the approval Assignment rule, what is your exact use case here so that we can help accordingly.

---

<div class="post-metadata">

**Author:** ![sreeram](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/sreeram/32/25311_2.png) [@sreeram](https://developer.sailpoint.com/discuss/u/sreeram)\
**Post date:** [November 15, 2023, 2:46pm UTC](https://developer.sailpoint.com/discuss/t/context-saveobject-method/20929/5 "2023-11-15T14:46:40Z")

</div>

Hi @iamnithesh @Remold @iamksatish

Thank you for your response.

To elaborate, the rule is an approvalAssignmentRule. I was using this rule to develop a custom approval mechanism. The custom approval requires 2 level of approvals(1. Manager, 2. Owner (custom owner fetched from a customObj)).  
Approval Mode: Serial  
approvalSplitPoint: Owner

I configured the LCM provisioning and approve and provision workflow to split the approval into parallel mode by defining the approvalSplitpoint & providing the approvalAssignmentRule to handle the logic.

However, after the manager’s approval, it skips the 2nd level of approval and directly provisions. Looking at the trace, It was observed that the workItem state is set to “Finished” after the manager’s approval.

[I’ve attached the post I made on the issue here, Any help is appreciated.](https://developer.sailpoint.com/discuss/t/access-request-approval-level-2-approval-skipped/18362)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sailpoint/original/2X/f/f2136700ed5e3703e0b85e02f6be799dacca7735.png) [@system](https://developer.sailpoint.com/discuss/u/system)\
**Post date:** [January 14, 2024, 2:47pm UTC](https://developer.sailpoint.com/discuss/t/context-saveobject-method/20929/6 "2024-01-14T14:47:28Z")

</div>

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