Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Friday, April 26, 2024 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - SalesLogix Scripting & Customization
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: SQL in script problem - Part 2
Andrew Grandin
Posts: 272
 
SQL in script problem - Part 2Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 22 Sep 09 3:22 AM
Hi All, i am trying to execute the following piece of SQL in the script of the Activity Details View plugin:

Dim strSQL

strSQL = "Update ACTIVITY Set NOTES = '" & memComments.Text & "'" & _
", LONGNOTES = '" & memComments.Text & "'" & _
", STARTDATE = '" & dteStartTime.DateTime & "'" & _
", DESCRIPTION = '" & pklRegarding.Text & "'" & _
", PRIORITY = '" & pklPriority.Text & "'" & _
", CATEGORY = '" & pklCategory.Text & "'" & _
", ACCOUNTNAME = '" & account & "'" & _
", CONTACTNAME = '" & contact & "'" & _
", OPPORTUNITYNAME = '" & opportunity & "' " & _
"Where ACTIVITYID = '" & Activity.Key & "' "
objSLXDB.ExecuteSQL(strSQL)

When i tried to execute this i got a type mismatch error, which i realised was due to me trying to convert the dteStartTime into text by enclosing it in ' ' as i have done with all the other variables.
Removing the ' and ' means the line now reads as: ", STARTDATE = '" & dteStartTime.DateTime & "'" & _

This successfully stopped the error from displaying but it does not insert the value of dteStartTime.DateTime into the database, but instead inserts 1900-01-01 00:00:00.000.

Can anyone suggest a solution to this?

Many Thanks.
[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: SQL in script problemYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 22 Sep 09 10:45 AM
Well, DateTimes' need a ' ' around them in a SQL statement, just like a string. without getting into ISO dates, which you should always use in raw SQL....

you could try
DIM sDATE
sDATE = dteStartTime.TEXT

and then
", STARTDATE = '" & sDATE & "'" & _

always good to:
MSGBOX strSQL (or application.debug.writeline strSQL)
objSLXDB.ExecuteSQL(strSQL)

[Reply][Quote]
LeVar Berry
Posts: 47
 
Re: SQL in script problemYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 22 Sep 09 2:45 PM
I have seen this happen with the the Date is actually Empty or equal to ""

Then you need to set it to null




[Reply][Quote]
Jeff Weight
Posts: 219
 
Re: SQL in script problemYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 23 Sep 09 12:34 AM
One other suggestion - it appears you may start having problems anytime someone uses an apostrophe in the notes or other string-type fields. Try doing something like this:
strSQL = "Update ACTIVITY Set NOTES = '" & Replace(memComments.Text, "'", "''") & "'" & _
", LONGNOTES = '" & Replace(memComments.Text, "'", "''") & "'" & _
", STARTDATE = '" & Application.BasicFunctions.TzLocalToGMT(dteStartTime.DateTime, 0) & "'" & _
", DESCRIPTION = '" & Replace(pklRegarding.Text, "'", "''") & "'" & _
", PRIORITY = '" & Replace(pklPriority.Text, "'", "''") & "'" & _
", CATEGORY = '" & Replace(pklCategory.Text, "'", "''") & "'" & _
", ACCOUNTNAME = '" & Replace(account, "'", "''") & "'" & _
", CONTACTNAME = '" & Replace(contact, "'", "''") & "'" & _
", OPPORTUNITYNAME = '" & Replace(opportunity, "'", "''") & "' " & _
"Where ACTIVITYID = '" & Activity.Key & "' "

That should escape the apostrophes so you don't have "Failed to Parse SQL" errors.

Also, I put in something that should help with the date. Can't remember if that will help the format, but the date needs to go in as GMT - I think. There are a few fields out there that aren't in GMT, but it's rare. I don't have an SLX database to look at right now, but chances are, if the type is DateTime, it should be saved in GMT.
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: SQL in script problemYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 23 Sep 09 3:39 AM
Thank you all for your replies. I managed to solve my problem with the following:
---------------------------------------------------------------------------------
Dim objRS
Dim account
Dim contact
Dim leader
Dim opportunity

account = getfield("ACCOUNT","sysdba.ACCOUNT","ACCOUNTID = '" & lveAccount.LookupID & "'")
contact = getfield("LASTNAME + ', ' + FIRSTNAME","sysdba.CONTACT","CONTACTID = '" & lveContact.LookupID & "'")
leader = getfield("LASTNAME + ', ' + FIRSTNAME","sysdba.USERINFO","USERID = '" & lveLeader.LookupID & "'")
opportunity = getfield("DESCRIPTION","sysdba.OPPORTUNITY","OPPORTUNITYID = '" & lveOpportunity.LookupID & "'")

Set objRS = objSLXDB.GetNewRecordSet
'Creates the structure of the recordSet.
strSQL = "Select * from Activity where ACTIVITYID = '" & Activity.Key & "'" 'DNL
objRS.Open strSQL, objSLXDB.Connection
'Adding the record To the database.
objRS.Fields("NOTES").Value = memComments.Text 'DNL
objRS.Fields("LONGNOTES").Value = memComments.Text 'DNL
objRS.Fields("STARTDATE").Value = dteStartTime.DateTime 'DNL
objRS.Fields("DESCRIPTION").Value = pklRegarding.Text 'DNL
objRS.Fields("PRIORITY").Value = pklPriority.Text 'DNL
objRS.Fields("CATEGORY").Value = pklCategory.Text 'DNL
objRS.Fields("ACCOUNTNAME").Value = account 'DNL
objRS.Fields("CONTACTNAME").Value = contact 'DNL
objRS.Fields("OPPORTUNITYNAME").Value = opportunity 'DNL

if chkTimeless.Checked = True then
objRS.Fields("TIMELESS").Value = "T" 'DNL
else
objRS.Fields("TIMELESS").Value = "F" 'DNL
end if

if chkAlarm.Checked = True then
objRS.Fields("ALARM").Value = "T" 'DNL
else
objRS.Fields("ALARM").Value = "F" 'DNL
end if

If cboDurationUnits.Text = "days" then
objRS.Fields("DURATION").Value = (CInt(cboDuration.Text) * 1440) 'DNL
else if cboDurationUnits.Text = "hours" then
objRS.Fields("DURATION").Value = (CInt(cboDuration.Text) * 60)
else if cboDurationUnits.Text = "minutes" then
objRS.Fields("DURATION").Value = cboDuration.Text
end if
end if
end if

objRS.Update
objRS.Close
Set objRS = Nothing

Dim strActID
strActID = Application.BasicFunctions.CompleteActivity(Activity.Key)
-----------------------------------------------------------------------------------

Unfortunately a new problem has now presented itself. As i am saving any changes to the activity before the Complete Form is called then if a user chooses to Cancel the Complete their changes are still saved, which is what was wanted.
However, we have now found the following problem scenario:

The user changes the Start Time to a later date.
They then click my button which saves the changes and takes them to the Complete screen.
They then choose to Cancel the complete process which closes down the forms but still saves their date change.
When they go back into the same activity the Alarm time (whether the alarm is checked or unchecked) has been re-calculated with the time lapse (whether hours or days) between the orignal date and the one they have now chnaged it to.
For example, as a test, i changed the date of one such activity forward 1 day. I followed the steps above and when i went back in the alarm time was changed to 1.0104 days.

Does anyone know why this happens?

Thanks for your time (especially due to how long this post is!!!!!)
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: SQL in script problemYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 23 Sep 09 9:28 AM
FINALLLLYYYY got it to work!!! thanks guys.
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: SQL in script problemYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 23 Sep 09 9:36 AM
And I was about to respond to the thread.

I guess you figured out that the ALARMTIME is a separate field (Separate table as well, since the one that is now being used is on USER_ACTIVITY), and that you may want to recalculate it (depending on your requirements).

[Reply][Quote]
Gopinath Srinivasan
Posts: 37
 
Re: SQL in script problemYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 29 Feb 16 3:34 PM

Hello


We are using client server version of Saleslogix. Current production version is 7.5.


We are in the process of modifying the Priority Field in the form screen "Phone Call", "Meeting", "To Do", "Personal Activity" from Schedule menu. Instead of Priority, Introduce the new field called "Activity" and associate a new picklist. I was able to do these changes. 


I have tried to create few records using Phone Call, Meeting, To Do and Personal Activity and I was able to create the entry in the Saleslogix DB. However, when I try to view through Activities, the new field doesn't show up


Please advise


 


Thanks




Gopinath Srinivasan

[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 4/26/2024 3:15:22 AM