Attachment is not getting delete from database

  • 6 November 2019
  • 4 replies
  • 39 views

Userlevel 3
Badge +9

Hi,

 

I have sql table. I am uploading and saving attachment in table from smartform. At the end of workflow, I want to delete the attachment from sql table. I am using smartobject update method, I tried scnull, null and Empty String from functions in context browser but attachment is not getting delete from database. Please see attachment

 


12131iCAD202E90F252615.png


4 replies

Hello  @YPawar, 


 


Looks like you are seeing this behavior because SQL SmartObjects try to default to the memo type instead of the file type in K2. You should be able to clone the SmartObject and make a few changes as detailed below to be able to clear the attachment field at the end of your workflow. 


 


1) Clone the SQL SmartObject using the 'Save As' feature 


2) Edit the new SmartObject and go to the 'Methods' tab 


3) Select the 'Update' method and click 'Edit' 


4) Add a parameter for this method that is the File type (name it something like FileIn, FileBlank, ect.) 


5) Select the 'ServiceObject Methods' tab, select the Update method, and click Edit 


6) Remap the File input property to the parameter that you just created 


7) Save and finish the SmartObject 


8) Use the update method from this SmartObject in your workflow 


 


Note: You will most likely want to pass the string "<file><name>scnull</name><content>scnull</content></file>" into the File column when you are clearing the attachment. This will prevent future issues with loading you're data into forms. 


 


Thanks, 
Sam

Userlevel 3
Badge +9

Hi Sam,

Smartobject property attachment is already of type File. as per your suggestion I am passing <file><name>scnull</name><content>scnull</content></file> but it is not working. Is it required to create parameter of type file instead of using existing smartobject property which is already of type file?

If I use update with scnull value from smartobject tester, it works but inside workflow it gives me an error, "Data at the root levle is invalid. Like1, Porition1".

Create a new SMO method from a store procedure instead.

Hello  @YPawar, 


 


Yes! You will need to create a parameter of the type 'File' that you can pass into the Update method. You will see that "Data at the root levle is invalid" error until the SmartObject method has been correctly configured. Please see my two attachments (MethodParams.png & MethodMapping.png) for some insight as to how I configured the method in my new SmartObject. 


 


Thanks, 
Sam



Reply