cancel
Showing results for 
Search instead for 
Did you mean: 

Can we use Numbering table to generate unique values for any field?

Former Member
0 Kudos

Hi Experts,

We have the following requirement - when a new Supplier is created using the Supplier Management -> Suppliers -> Create Supplier screen, there is a mandatory field External ID. This field should be pre-populated with a meaningful unique value, like say VEN-001. I tried creating a new numbering table (please see the attached screenshot) but not sure how to make the External ID field refer to this value. Please help. If this is not the way to achieve this requirement, please let me know the correct way. I first thought of writing a Script Definition but found that numbering table has no iAPI defined.. so cannot access it from script.

Thanks in advance!

- Gayathri

Accepted Solutions (1)

Accepted Solutions (1)

kushagra_agrawal
Active Participant
0 Kudos

HI Gayathri,

Numbering Table generates the UNIQUE_DOC_NAME of the Supplier. If you want to copy the UNIQUE_DOC_NAME to the External ID then you need to write 2 scripts on the class Supplier(607):

  • POST_CREATE: In this script you need to set temporary EXTERNAL_ID for the supplier so that system allows to save the supplier and generates document Id
  • POST_SAVE : In this script you need to copy the generated document id to the EXTERNAL_ID

Hope it helps!

Best,

Kushagra A

Former Member
0 Kudos

Thanks for the quick reply Kushagra. External Id is a key field in masterdata.Vendor and I am not able to update it after it is saved in db. For now I have written a script on Create event of Supplier(607). This script creates a string like "VEN-xxxx" where xxxx is a four-digit random number generated using java.util.Random. I am not able to maintain a running sequence number for this "xxxx" value (that is what the customer really wants).. is there some sequence table other than Numbering table that i can access using iAPIs?

Thanks,

Gayathri

kushagra_agrawal
Active Participant
0 Kudos

HI Gayathri,

As mentioned earlier, you can use Supplier Numbering Table for setting the External ID in the sequential manner generated from the Supplier Numbering Table. For this you need to write the logic of setting the DocumentID of the Supplier to the EXTERNAL_ID on SAVE Event.

Let me know if it works for you.

Best,

Kushagra A

Former Member
0 Kudos

I had missed calling the supplier home save in my earlier code. Thanks Kushagra, this is the correct Save event script that updates external id with same value as doc id:

//Supplier Post Save Script

//Check if Ext id is already updated to Unique Doc ID

if (doc.getDocumentId().equals(doc.getExternalId()))

    return;

// Update the External Id with the Document Id...

try {

    supHome = doc.getIBeanHomeIfc();

    doc.setExternalId(doc.getDocumentId());

    supHome.save(doc);

} catch(e) {

    supHome.save(doc);

}

Answers (0)