Solved

Function to Count attachments of particular Doc Class? Apps9


Userlevel 6
Badge +13
  • Hero (Customer)
  • 355 replies

I’m looking to add a custom field to the ‘Customer Invoices’ view that returns the number of attachments of a certain Document Class.  

Does anyone know if there is an existing Function I could adapt to retrieve this, please?  

Apps9 (moving to Cloud soon...)

 

 

Many thanks!

icon

Best answer by Sahan Udana 27 June 2023, 03:41

View original

11 replies

Userlevel 6
Badge +12

@PRODQ 

Below is the function that get called in a certain window to count the number of documents attached. 

DOC_REFERENCE_OBJECT_api.Get_Obj_Conn_Client_Hit_Count

 might be useful to start with your requirement. 

Userlevel 6
Badge +13

Thanks for this, Sahan.  I had tried that but couldn’t get my head around what was required here.  

service_name - database ie IFS1?
   lu_name - CustomerOrderInvHead
   key_ref - ???
   service_view_name - ???

 

ifsapp.doc_reference_object_api.Get_Obj_Conn_Client_Hit_Count(service_name,lu_name,key_ref,service_view_name)
 

Any suggestions gratefully received!

 

Linda

Userlevel 6
Badge +12

Hi PRODQ,

There are 2 ways to get this.

Method 1:

Open the debug console and check the below call it has the relevant information for Lu_name_key_ref and service

For ex:

This is the parameters when I we get in the customer Order window

In here Lu_name = CustomerOrder

Key_ref = ORDER_NO=*4325^

Service_name = DocReferenceObject (this is the service name for documents)

 

Method 2:

Attach a document to a relevant window and go to document object connections window and search the relevant record via doc_no. You can easily get the Keyref and Luname(But I notice for some LU’s this can be different)

 

I can see there is method(app10) exists only accept 2 parameters (luname and keyref) which will return the documents attached

 

 

result for the above example

 

 

Hope this is helpful.

 

Regards,

Sahan

Userlevel 6
Badge +13

This has been helpful, Sahan, so thank you but I’m just not quite there. 

 

This is what the debug shows when I query in Customer Invoice view

 

 

I’m “translating” this as follows:

ifsapp.doc_reference_object_api.Get_Obj_Conn_Client_Hit_Count('DocReferenceObject',CustomerOrderInvHead,key_ref,null)

 

… which falls at the KEY_REF stage

Do you have any suggestion as to what should be entered as the ‘KEY_REF’ parameter at all?

Any thoughts much appreciated.

 

Thanks

 

Linda

Userlevel 6
Badge +12

@PRODQ 

You should use the highlighted value in this case

 

Also you can use this 2 parameters call instead of 4 parameters call would be easy

 

Userlevel 6
Badge +13

Hi Sahan

Thanks for continuing to stick with me. 

Your suggestion is OK for that particular invoice but I want to use this function to add a custom field to the customer invoices view that counts the attachments against each invoice.  

 

I have tried your suggested

ifsapp.doc_reference_object_api.Get_Obj_Conn_Client_Hit_Count(lu_name_ => :lu_name_,
                                                                                                             key_ref_ => :key_ref_)


but got the following when trying to validate it so it seems I can’t use just 2 parameters

 

This does work but I need to be able to add a parameter not 'COMPANY=PD^INVOICE_ID=620693^'

ifsapp.doc_reference_object_api.Get_Obj_Conn_Client_Hit_Count('DocReferenceObject','CustomerOrderInvHead','COMPANY=PD^INVOICE_ID=620693^',null)

 

When I enter this ...

ifsapp.doc_reference_object_api.Get_Obj_Conn_Client_Hit_Count('DocReferenceObject','CustomerOrderInvHead',KEY_REF,null)

… it errors on validation

 

I can’t help feeling I’m so close but not quite there!  Any other suggestions would be most gratefully received.  

 

Thank you.

 

Linda

 

Userlevel 6
Badge +12

@PRODQ 

Can you try the following.

In the custom field select a Read only type

 

then Implementation type = Select

Arguments :v.company,v.invoice_id

Select statement : 

Select ifsapp.doc_reference_object_api.Get_Obj_Conn_Client_Hit_Count('CustomerOrderInvHead','COMPANY='|| :company || '^INVOICE_ID=' || :invoice_id ||'^') from dual

Select the view highlighted as well.

 

 

hope this will fix the problem. 

Userlevel 6
Badge +13

Another step closer, @Sahan Udana, thank you.  It validated OK but error’d when I came to Approve/Publish.  

 

Is it because there are only two arguments - nothing references the view CustomerOrderInvHead?

 

 

Userlevel 6
Badge +12

@PRODQ 

Yes based on the error it seems like that. Please try out the 4 parameter one. 

ifsapp.doc_reference_object_api.Get_Obj_Conn_Client_Hit_Count(DocReferenceObject','CustomerOrderInvHead','COMPANY='|| :company || '^INVOICE_ID=' || :invoice_id ||'^',NULL) from dual

Mine worked fine in app10 database when I tried. Which version are you in?

Userlevel 6
Badge +13

Hi Sahan

 

That’s amazing!  Thank you so much.  This worked with the additions highlighted below

 

select ifsapp.doc_reference_object_api.Get_Obj_Conn_Client_Hit_Count(DocReferenceObject','CustomerOrderInvHead','COMPANY='|| :company || '^INVOICE_ID=' || :invoice_id ||'^',NULL) from dual

 

I am on Apps9.  

 

I appreciate you sticking with me on this.  Most helpful.  

Linda

Userlevel 6
Badge +12

No worries. Glad I could help out :) 

Reply