0

How would I check to see if my SKU text field is unique and that no other values SKU of that value is in the table?

Hi there,

I have a table called Product with a Text Field called SKU how would i check that the value of the new or updated SKU is unique and does not already exist within the table?

On a second note would there be anyway of randomly generating an SKU of six digits i.e 123456 that odes not already exist in the SKU field?

Any help appreciated

 

Regards

 

Paul

4 replies

null
    • Nick
    • 4 yrs ago
    • Reported - view

    One simple way to check for duplicates (formula field)

     

    let d := SKU;

    cnt((select Product where SKU = d).SKU)

     

    Where the result is 2 it's double...

    • Thunderfix
    • Paul_Kidd_thunderfixco
    • 4 yrs ago
    • Reported - view

    Many thanks Nick I will give it a try.

    • Thunderfix
    • Paul_Kidd_thunderfixco
    • 4 yrs ago
    • Reported - view

    I have used the following code in both trigger on create and update but no warning is displayed, is there something i am doing wrong?

    let d := SKU;
    let countSKU := cnt((select Product where SKU = d).SKU);
    if countSKU > 1 then alert("Duplicate!") end

Content aside

  • 4 yrs agoLast active
  • 4Replies
  • 2067Views