NetTalk Central

Author Topic: How to display a Clarion variable in a javascript message  (Read 3503 times)

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Using MSSQL. I am checking 2 fields. There is a key for the combination of the 2 fields. I can't make the key unique because of the problem with MSSQL whereby a new record creates the 2 fields as empty. If a second person tries to create a record at the same time a duplicate error throws up before any fields can be entered. If the combination of the 2 fields already exists I want to display an alert like this:-
p_web.Script('alert("This waybill exists on trip ' & p_web.GSV('WAYALIAS:TripID') & ' You cannot accept this Waybill");')
Currently the message displays without the value of WAYALIAS:TripID

Can I do it?
Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: How to display a Clarion variable in a javascript message
« Reply #1 on: July 03, 2014, 01:11:02 AM »
>>  If the combination of the 2 fields already exists I want to display an alert like this:-

p_web.Script('alert("This waybill exists on trip ' & p_web.GSV('WAYALIAS:TripID') & ' You cannot accept this Waybill");')

>> Currently the message displays without the value of WAYALIAS:TripID

what embed point are you embedding this into? and what does your code up to this point look like? Are you using the Alias to search for a record?

Cheers
Bruce

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Re: How to display a Clarion variable in a javascript message
« Reply #2 on: July 03, 2014, 03:30:10 AM »
Hi Bruce
This is in a procedure routine which is called from the various Validate::variable routines in 5.Add Server Side Code here
The procedure routine is:
TTestForDuplicate ROUTINE
    IF p_web.GSV('WAY:WaybillNumber') ='' OR  p_web.GSV('WAY:WayCustID') ='0'
        p_web._trace('waybill or custid blank')
    ELSE   
    p_web._trace('waybill Number ' & p_web.GSV('WAY:WaybillNumber')  & ' custid ' &  p_web.GSV('WAY:WayCustID'))
        access:WaybillAlias.Open()
        Access:WaybillAlias.UseFile()
        WAYALIAS:WaybillNumber=p_web.GSV('WAY:WaybillNumber')
        WAYALIAS:WayCustID = p_web.GSV('WAY:WayCustID')
        GET(WaybillAlias,WAYALIAS:KEY_CustomerIDWayBillNumber)
        IF ERRORCODE()
            p_web._trace('not found')
            DuplicateFound=FALSE
        ELSIF WAYALIAS:NoImage=FALSE
            p_web._trace('waybill delivered')
            p_web.Script('alert("This waybill has been delivered.Change the number");')
           WaybillChanged=FALSE
           DuplicateFound=TRUE
         ELSE
            p_web._trace('on another trip ')
            p_web.Script('alert("This waybill exists on trip ' & p_web.GSV('WAYALIAS:TripID') & ' You cannot accept this Waybill");')         
            DuplicateFound=TRUE
        END   
        IF DuplicateFound = TRUE
            p_web.SSV('WAY:WaybillNumber','')
            p_web.SSV('WAY:WayCustID',WAY:WayCustID)
        END
        Access:WaybillAlias.Close()       
    END
Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Re: How to display a Clarion variable in a javascript message
« Reply #3 on: July 06, 2014, 09:59:07 PM »
Answer
I should not have used  p_web.GSV('WAYALIAS:TripID') since this was a value in a lookup I did in the routine so I should have just used WAYALIAS:TripID
Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186