Quantcast
Channel: Adobe Community : All Content - ASP VBScript Development (read only)
Viewing all articles
Browse latest Browse all 106

check new element for multiple fields

$
0
0

I want check two fields if duplicated or not before insert record, I use custom trigger as shown in addt documentation like that:

 

<%

'start Trigger_Custom trigger

Function Trigger_Custom (ByRef tNG)

'Trigger that checks if two combined fields are unique

Dim centrl

Dim tel

Dim query

 

centrl = tNG.getColumnValue("centrlID")

tel = tNG.getColumnValue("phoneNO")

 

query = "SELECT * FROM phone_services where centrlID = " & KT_escapeForSql(centrl,tNG.getColumnType("centrlID")) & " AND phoneNO = " & KT_escapeForSql(tel,tNG.getColumnType("phoneNO"))

 

on Error Resume Next

set check_result =  tNG.connection.Execute(query)

If Err.Number <>0 Then

Set check_failure = new tNG_error

check_failure.init "Could not access database!", Array(), Array()

Set Trigger_Custom = check_failure

Else

if(check_result.recordCount() <>0 ) Then

Set not_unique = new tNG_error

not_unique.init "A message with the same subject and content already exist. You cannot enter duplicates", Array(), Array()

Set Trigger_Custom = not_unique

else

Set Trigger_Custom = nothing

end if

end if

On Error GoTo 0

End Function

'end Trigger_Custom trigger

%>

 

But that code returns that error always:

 

Error:

A message with the same subject and content already exist. You cannot enter duplicates

 

any hepl please. many thanks.


Viewing all articles
Browse latest Browse all 106

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>