Jim Strickland Posted November 28, 2006 Posted November 28, 2006 I have a notes field that is a simple text field. I have created a script to add a new note with date, time, and user name. Now the users of this database have asked if the entries can be placed at the top of the notes so the notes will always be sorted from most recent to oldest. Is this possible? If so, what would I need to add to my script?
Ender Posted November 28, 2006 Posted November 28, 2006 Do you have a separate field for the new note to be added, or do you just want to insert the cursor after the Date/Time/Username?
Jim Strickland Posted November 28, 2006 Author Posted November 28, 2006 Do you have a separate field for the new note to be added, or do you just want to insert the cursor after the Date/Time/Username? All notes are in the same field. I just want to insert the Date/Time/Username/Cursor at the top of the filed instead of the bottom.
T-Square Posted November 29, 2006 Posted November 29, 2006 I think: Set Field[YourField; "NewText" & {Pilcrow} & YourField] Should work in your script. Note that the "{Pilcrow}" is the new paragraph symbol. Although I'd go for a separate Notes table and store each note as a separate record with timestamp, user and data fields. A portal sorted in date descending order then accomplishes the users' request... David
Genx Posted November 29, 2006 Posted November 29, 2006 Start -- Run -- charmap will let you choose screwed up characters - like pilcrow - on xp.
Jim Strickland Posted November 29, 2006 Author Posted November 29, 2006 I think: Set Field[YourField; "NewText" & {Pilcrow} & YourField] Should work in your script. Note that the "{Pilcrow}" is the new paragraph symbol. Although I'd go for a separate Notes table and store each note as a separate record with timestamp, user and data fields. A portal sorted in date descending order then accomplishes the users' request... David I tried Set Field. When I chose specify calculated result and entered the following: WiSARD_Billing::Notes; "NewText" & ¶ & WiSARD_Billing::Notes I got this message when trying to save. An operator (e.g. +, -, *, ...) is expected here.
Ender Posted November 29, 2006 Posted November 29, 2006 In the Set Field[] statement, the first argument (everything in front of the semicolen) is the target field. The calc is everything after the semicolen. But Set Field[] alone will not put the cursor after the newly inserted text. You might try it this way: Set Variable [ $text ; getastext(get(currentdate)) & " " & getastime(get(currenttime)) & " " & Username & ": " ] Set Field [ WiSARD_Billing::Notes; $text & ¶ & WiSARD_Billing::Notes ] Set Selection [ WiSARD_Billing::Notes; Start Position: length($text) + 1; End Position: length($text) + 1 ]
T-Square Posted November 30, 2006 Posted November 30, 2006 Jim-- You got that error because I gave you an error. The pilcrow (Start->Run->CharMap is too much out of my way, thanks anyway genx ) should be enclosed in quotation marks. Putting quotation marks around it will fix the error. And if you DO need to put the cursor at the end of the new note, Ender's approach will work. But consider splitting this info out into a separate table; it really gives you a lot of other options (like testing how many notes got added on a given date, or how many notes each staff member has added, etc.)... David
Ender Posted November 30, 2006 Posted November 30, 2006 Good news: in FM7 and later, the quotes are not required around a ¶ in a calc. But consider splitting this info out into a separate table; it really gives you a lot of other options (like testing how many notes got added on a given date, or how many notes each staff member has added, etc.)... I totally agree. It's also useful to be able to have different properties (fields) on each note, so they can be sorted, filtered, and summarized in different ways.
Recommended Posts
This topic is 6629 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now