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!
|
|
Sleep
Posted: 18 May 10 10:55 AM
|
How do i make saleslogix wait for a while like 5 sec. I am on version 7.2. i tried wscript.sleep 5000. its not working. it says variable not defined for wscript.
please help.
thanks Uma Sankar |
|
|
|
Re: Sleep
Posted: 18 May 10 2:32 PM
|
This is clumsy, but should work: write a loop that keeps calling Application.DoEvents until the desired amount of time has passed. You can use the Now and DateAdd functions to find the current time, add 5 seconds to it, and then loop until that value is less than the value returned by the Now function.
Unless someone else knows a better way... |
|
|
|
Re: Sleep
Posted: 19 May 10 12:08 AM
|
The main question here is why do you need to sleep for 5 seconds. Are you waiting for some external process? Or are you looking for the Program to become responsive while doing a lot of work?
Either way, a Loop is not such a good idea as it will use a lot of CPU and would lock the app for those 5 seconds.
If you really need to wait for some events, I would suggest that you put your code inside a form, and then use a Timer Object: - Add a timer control on the Form. - Split your code between what needs to happen before, and what needs to happen after the wait - Set the Interval on the Timer control, and Enable it when you are ready to pause (or go into your "sleep" mode) - Add the rest of the code to Event handler on the Timer control
Again, depending on what you are doing this may be simple or complex, but the wait won't lock the app, nor cause a spike in CPU. |
|
|
|
Re: Sleep
Posted: 19 May 10 9:27 AM
|
We are facing a problem where 2 people are trying to update the same field at the same time. Its the userfield5 of the Contact table, which is later on used for mailmerge by the application and send emails to user.
The first user clicks the email button, the userfield5 is updated with his ticketnumber, and mailmerge process continues after that. after a few lines of code, the mailmerge takes the ticket number from the userfield and inserts some ticket data into the mailmerge document and sends it to the customer.
what is now happaneing is, just before the mail merge takes the userfield's value, somebody else clicks the email button and now the userfield has the new ticketid. because of this, the first user's email has a wrong ticket number now.
this is happening when two people work on two different tickets of the same contact at almost the same time.
I was thinking if i can make the second person wait for a while, when the contact is already being worked on.
any suggestions would be appreciated.
thanks Uma |
|
|
|
Re: Sleep
Posted: 19 May 10 9:34 AM
|
Indeed I would suggest that the second person waits for a while, but rather than forcing the Wait via the code looping or sleeping, just go ahead and create a Retry/Cancel loop:
Sub DoSomething .... Do While FieldStillInUse() If MsgBox("The xxx is still in use, do you want to retry", vbYesNo) = vbNo then Exit Sub End If Loop 'Out of loop, good to continue 'Do Mail Merge, etc, etc End Sub
Function FieldStillInUse 'Add your test here, if ok to continue return false FieldStillInUse = result End Function |
|
|
|
Re: Sleep
Posted: 19 May 10 10:30 AM
|
Yes, Raul..that is what i suggested, but the users want that to be automated. they dont want the users to be clicking message boxes... |
|
|
|
Re: Sleep
Posted: 20 May 10 4:51 AM
|
Why not generate the e-mail from the Ticket - assuming the Ticket is associated with the correct contact - and avoid all this malarkey? |
|
|
|
Re: Sleep
Posted: 20 May 10 8:25 AM
|
I am not an expert in mailmerge, but my assumption was mailmerge can be done only from a contact level. Atleast the mailmerge template which was created here is that way. |
|
|
|
Re: Sleep
Posted: 20 May 10 8:52 AM
|
Originally posted by Sankar
I am not an expert in mailmerge, but my assumption was mailmerge can be done only from a contact level. Atleast the mailmerge template which was created here is that way. |
|
Your assumption is incorrect - you can mail merge from the context of tickets. But ... I'm not sure about picking up the details of the 'current' ticket in the MM - would have to try it out.
You might also check the code behind the 'E-mail' button on the Ticket Detail form for ideas. Sounds like it would do what you needed, with a bit of tweaking. |
|
|
|