Re: HTTP Basic Auth for a REST request

2019-07-17 Thread Noah via 4D_Tech
Ha!
Moments after sending, I tried one more thing:
HeaderNames_at{1}:="Authorization"
HeaderValues_at{1}:="Basic TGFuZ2xvOlBhc3R1cml6ZWQ="

That worked!
So I guess my question is much simpler.

How would I manually base64 encode the needed string?

Many thanks!

On Wed, Jul 17, 2019 at 11:16 AM Noah  wrote:

> We have used Basic Auth in other parts of our infrastructure with Great
> success, but have not had the need to pass authentication from 4D, until
> now.
> We are trying to replace a SOAP service with a REST based 'pass through'
> service.
>
> Using HTTPS to protect a basic auth header meets the minimum requirements
> for security.
>
> https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication#Basic_authentication_scheme
>
> I have built a prototype web service to handle these requests, and can
> interact with it via "postman"
>
> Here is some generated code from the postman app:
> wget --quiet \ --method GET \ --header 'authorization: Basic
> TGFuZ2xvOlBhc3R1cml6ZWQ=' \ --output-document \ -
> https://prototype.url.com/ppp/201905
>
> Trying to build this out in 4D, I have the following:
>
> C_TEXT(URLText_t)
> C_TEXT(Text_t)
> URLText_t:="https://prototype.url.com/ppp/201905;
> ARRAY TEXT(HeaderNames_at;2)
> ARRAY TEXT(HeaderValues_at;2)
> HeaderNames_at{1}:="Username"
> HeaderNames_at{2}:="Password"
> HeaderValues_at{1}:="Langlo"
> HeaderValues_at{2}:="Pasturized"
> $httpResponse:=HTTP Get(URLText_t;Text_t;HeaderNames_at;HeaderValues_at)
>
> However, 4D is not generating the correct (base64 encoded) header as it
> initiates the HTTP Get.
>
>
> In other languages (like Javascript) you can generate a base64 encoded
> string like this:
>
> var user = 'user';var password = 'password';var base64encodedData = new 
> Buffer(user + ':' + password).toString('base64');
>
> I have looked at the base64-encode method for 4D, but am not sure how I
> could accomplish the same thing.
> https://doc.4d.com/4Dv16/4D/16.5/BASE64-ENCODE.301-4227612.en.html
>
> Has anyone else already been down this road?
> Any suggestions on passing HTTP auth out of 4D to an external service?
>
> Many thanks,
> Noah
>
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

HTTP Basic Auth for a REST request

2019-07-17 Thread Noah via 4D_Tech
We have used Basic Auth in other parts of our infrastructure with Great
success, but have not had the need to pass authentication from 4D, until
now.
We are trying to replace a SOAP service with a REST based 'pass through'
service.

Using HTTPS to protect a basic auth header meets the minimum requirements
for security.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication#Basic_authentication_scheme

I have built a prototype web service to handle these requests, and can
interact with it via "postman"

Here is some generated code from the postman app:
wget --quiet \ --method GET \ --header 'authorization: Basic
TGFuZ2xvOlBhc3R1cml6ZWQ=' \ --output-document \ -
https://prototype.url.com/ppp/201905

Trying to build this out in 4D, I have the following:

C_TEXT(URLText_t)
C_TEXT(Text_t)
URLText_t:="https://prototype.url.com/ppp/201905;
ARRAY TEXT(HeaderNames_at;2)
ARRAY TEXT(HeaderValues_at;2)
HeaderNames_at{1}:="Username"
HeaderNames_at{2}:="Password"
HeaderValues_at{1}:="Langlo"
HeaderValues_at{2}:="Pasturized"
$httpResponse:=HTTP Get(URLText_t;Text_t;HeaderNames_at;HeaderValues_at)

However, 4D is not generating the correct (base64 encoded) header as it
initiates the HTTP Get.


In other languages (like Javascript) you can generate a base64 encoded
string like this:

var user = 'user';var password = 'password';var base64encodedData =
new Buffer(user + ':' + password).toString('base64');

I have looked at the base64-encode method for 4D, but am not sure how I
could accomplish the same thing.
https://doc.4d.com/4Dv16/4D/16.5/BASE64-ENCODE.301-4227612.en.html

Has anyone else already been down this road?
Any suggestions on passing HTTP auth out of 4D to an external service?

Many thanks,
Noah
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: WA Evaluate JavaScript in 16.4

2018-12-20 Thread Noah via 4D_Tech
Thanks for the quick reply!

We had constructed a minimal test: an external js file that contains
*alert('hello')* on a single line and nothing else.

We may have now narrowed the scope of this issue to WA Execute JavaScript's
ability to handle the '\n' in the javascript that it reads from a file.

When the file is read into 15.4 or 16.4 the returned text is
*alert('hello')\n*. This was not a problem in 15.4, but the \n creates a
problem with WA Evaluate JavaScript in v16.4.

Overcoming the bug by processing the read JS (to remove the \n) does the
trick for our very simple test case (JavaScript in external files that are
only a single line). Web areas in v16.4 will now 'alert' as expected.

$tJS_path:=Get 4D folder(Current resources folder)+"ncs_test.js"
DOCUMENT TO BLOB($tJS_path;$bDoc)
$test_js:=BLOB to text($bDoc;UTF8 text without length)
  // replace the carriage return \n with ''
$codeBody:=Replace string($test_js;Char(10);"")
WA Evaluate JavaScript(wa;$codeBody)

However, this is obviously not going to solve our larger problem of being
able to load JavaScript libraries to scrape a web page.

The JavaScript code in the external files contains comments... and perhaps
other nuances that would render the above solution insufficient.




On Thu, Dec 20, 2018 at 9:58 AM John DeSoi via 4D_Tech <4d_tech@lists.4d.com>
wrote:

> Try turning 'Use embedded rendering engine' off for the web area. And
> verify your JavaScript code works outside of 4D in Safari when using Mojave.
>
> John DeSoi, Ph.D.
>
>
> > On Dec 20, 2018, at 11:10 AM, Noah via 4D_Tech <4d_tech@lists.4d.com>
> wrote:
> >
> > The parent form:
> > Case of
> >: (Form event=On Load)
> >WA OPEN URL(wa;"https://google.com/;)
> >WA SET PREFERENCE(wa;WA enable JavaScript;True)
> >WA SET PREFERENCE(wa;WA enable Web inspector;True)
> > End case
> >
> > 'Use embedded rendering engine' is checked.
> >
> > Has anyone else experienced this? Any suggestions?
>
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

WA Evaluate JavaScript in 16.4

2018-12-20 Thread Noah via 4D_Tech
Good morning!

SUMMARY:
In 16.4 (interpreted mode) we have a web area which displays a web page
that is not under our control. We had devised a way to scrape the webpage
with a custom library of JavaScript files that we kept in the resources
folder. We find that in 16.4 the WA Evaluate JavaScript does not evaluate
the JavaScript from external files.

HISTORY:
We recently moved from 15.4 to 16R6 (which was a mistake, since it is not
Mojave compatible). When we did, we had to update various aspects of our
app to work with the new version. The web area was one area that required
our attention. In the end, it appeared that we just needed to check the
'use embedded webkit'. When a development machine was upgraded to Mojave we
were locked out of developing in 16R6, so (at the advice of 4D support) we
quickly changed to 16.4 (which is actively supported).
The problem was that we assumed there would be no significant differences
between 16.4 and 16R6. There were several changes (method name conversions)
that happened automatically, but (more importantly) the WA Evaluate
JavaScript stopped working with our JS code loaded from external files.

Here is the relevant testing code from the web area:
Case of
: (Form event=On End URL Loading)

  // test the 'fetching' of javascript
$tJS_path:=Get 4D folder(Current resources
folder)+"SciQuest"+<>ktDir_Separator+"ncs_test.js"
DOCUMENT TO BLOB($tJS_path;$bDoc)
$test_js:=BLOB to text($bDoc;UTF8 text without length)
WA Evaluate JavaScript(wa;$test_js)
  // end test
End case

The parent form:
Case of
: (Form event=On Load)
WA OPEN URL(wa;"https://google.com/;)
WA SET PREFERENCE(wa;WA enable JavaScript;True)
WA SET PREFERENCE(wa;WA enable Web inspector;True)
End case

'Use embedded rendering engine' is checked.

Has anyone else experienced this? Any suggestions?
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Using 4D with Git...

2018-11-07 Thread Noah via 4D_Tech
We have been exporting our project and form methods to flat files that we
track in the Bitbucket GIT service. We chose Bitbucket because it has free
private repos.
What does this accomplish? It allows us to keep a record of changes (but no
smooth way to revert changes, and no way to track form changes).

We are presently having to re-write our export method to work with version
16 (64-bit) because of the change in file path separators.
We are also excitedly anticipating better support for version control!

On Thu, Nov 1, 2018 at 1:31 AM Epperlein, Lutz (agendo) via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> If bitbucket works like a usual git server (I don't have experiences with
> it),
> you have to *clone* your repository (the remote one at github or the local
> repo) to bitbucket. The repository contains the whole history of all
> commits.
> You don't lose anything. Subsequent sync operations such as push and pull
> synchronizes the repositories, again with all commits.
>
> Regards
> Lutz
>
> > -Original Message-
> > From: 4D_Tech [mailto:4d_tech-boun...@lists.4d.com] On Behalf Of Robert
> > ListMail
> > via 4D_Tech
> >
> > If you start with your own local git data and then publish the project
> to
> > GitHub and
> > then move it to bitbucket do you get to see the granularity of the
> commits
> > and have all
> > of the other options offered via Git? Or, do you lose the history with
> each
> > transition?
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Changes to variable initialization in v16?

2018-08-02 Thread Noah via 4D_Tech
So we saw this error pop up elsewhere in our beta test of v16 under the
same circumstances:

Error:"A variable was expected"
the line of code is: SET QUERY DESTINATION(Into variable;$LQueryResult)

Looking at the Unique Values project method in the example on this page:
http://doc.4d.com/4Dv16/4D/16.3/SET-QUERY-DESTINATION.301-3651871.en.html
led me to believe that I could declare the destination variable as a
C_LONGINT.

I added a declaration for the local variable $LQueryResult and the method
ran without a problem.

So has the behavior of SET QUERY DESTINATION changed in such a way that
(contrary to what is in the documentation), the variable must exist before
the method is called?



On Thu, Aug 2, 2018 at 7:12 AM Chip Scheide via 4D_Tech <
4d_tech@lists.4d.com> wrote:

>
> > In addition to consistency & clarity in showing variable type, do you
> from my 'Conventions' (all comment) method
>
>   //Variables
>   //all process or interprocess vars are preceded by a type designator
>   //I do not hold these conventions for local variables
>   //this is in the form of :
>   //letter(s)_variablename
>   //letters for designator are always lower case
>
>   //Variable names are always 1 word, with separate 'phrases' connected
> by an underscore
>   //the first letter of each 'phrase' is always capitalized.
>   //ex: al_My_Longint_Array
> variable naming specifics are NOT included here
>
> >do you
> > put   any / much / no   thought into using the variable names to
> > indicate business―vs technical―purpose?
>
> Depending on the code usage, it is not always possible to separate the
> 2 things - technical vs Business. If the code is generic (like might be
> found in a component) then the primary consideration for variable
> naming will be technical usage; however, Reporting, and/or user
> interface most often the usage in the interface is the paramount
> consideration for variable naming.
>
> i.e.
> Component : $Array_Pointer, $Loop_Counter, $Return_value
> Interface : r_Invoice_Line_Total, r_Invoice_Grand_total,
> l_Line_Item_Count
>
> For code that spans the gap, naming will be what seems to make the most
> sense. I *try* to make the code as readable, and 'self documenting' as
> possible, even in generic code I try to avoid code like this
> (completely made up):
>
> For ($i;1;$x)
>   $y:= $z+$A+$f*$t/$R+$G-$k
>   $v:=$y+$v
> end for
>
> and prefer code more like this (also made up):
>
> $Record_Count := Records in set("SomeSetName")
> 
> For($i;1;$Record_Count)
>   $Record_Total:= [table]Field1 *[table]Field2) + ([table]Field3 /
> [table]Field4)
>   $Grand_Total := $Grand_Total + $Record_Total
>   next record([table])
> end for
>
>
>
>
> On Wed, 1 Aug 2018 21:17:40 -0400, David Eddy via 4D_Tech wrote:
> >
> >
> >> On Aug 01, 2018, at 3:00 PM, Jody Bevan  >> > wrote:
> >>
> >>
> >> 2. The naming convention must clearly show the type of variable.
> >
> > In addition to consistency & clarity in showing variable type, do you
> > put   any / much / no   thought into using the variable names to
> > indicate business―vs technical―purpose?
> >
> > 
> > David Eddy
> > Babson Park, MA
> >
> > W: 781-455-0949
> >
> > de...@davideddy.com 
> > **
> > 4D Internet Users Group (4D iNUG)
> > Archive:  http://lists.4d.com/archives.html
> > Options: https://lists.4d.com/mailman/options/4d_tech
> > Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> > **
> ---
> Gas is for washing parts
> Alcohol is for drinkin'
> Nitromethane is for racing
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Changes to variable initialization in v16?

2018-08-01 Thread Noah via 4D_Tech
Many thanks for so much helpful feedback!

It is wonderful to hear the different opinions, viewpoints (and the
respective justifications) from seasoned developers on a variety of best
practices for the 4D language framework.

We used to be in the habit of chipping away at compiler errors before
releasing a new version, but had grown out of practice as there some that
are quite tricky (and time consuming) to track down (and even more
difficult to test that the original intended functionality still remains).
However, after some sleuthing, we have just 32 syntax errors.

4D is remarkable in that it does allow for a very small team (or even a
single person) to be very productive and to bring a lot of functionality in
a short amount of time. Although, when there have been several 'cooks in
the kitchen' developing one application over 20 years, it is quite daunting
to consider the network of dependencies that exist (and what 'might break'
if we make a change).

Ad-hoc patching is highly unfavorable, but that is how it was set up when I
arrived. Currently, the users can happily continue working without
interruption and there is no compelling reason to make a change in the
existing architecture right now.
Thank you for confirming that there is nothing major changing between v15
and v16. We originally observed that (for at least one window) what worked
in v11-v15 was not working in v16. It was simple to 'patch' fix, but as
many of you have pointed out, we likely have some type coercion taking
place.

I have traced the issue (what this original email was about) in the
debugger.
There is a parent window with a tabbed interface, the variable in question
was declared as a local variable in the form method, the 'on load' event.
When selecting a different tab, the variable became 'UN-initialized" and
produced a runtime error.
It was a very common variable name, so maybe we can take a different route
of investigation (after getting through the compiler checks).

Most of the errors are along the lines of "The result of the function is
not compatible with the expression"

Again,
Many thanks to the community of folks who added to this thread!



On Wed, Aug 1, 2018 at 1:40 PM Keisuke Miyako via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> no, nothing major has changed with regards to form events and scope of
> variables between v15 and v16.
>
> I am not saying that running interpreted is good or bad.
>
> when you run "syntax check" the only thing it checks is typing integrity.
> on other words, the hundreds of errors it reports are basically all typing
> errors.
>
> you could track the execution sequence with debug logging (database
> parameter #34) or TRACE,
> but the order of form events is really not the issue the here.
>
> you can forgive the typing integrity and do an ad hoc patch (like you
> described in the original post) or face the typing issue head on,
> but dealing with the error as if it was because of "scoping of variable
> initialisation and form events" is the wrong approach, in my opinion.
>
> 2018/08/01 23:34、Noah via 4D_Tech <4d_tech@lists.4d.com 4d_tech@lists.4d.com>>のメール:
>
> Is is really 'that bad' to run in interpreted mode?
> My original question was simply about the scoping of variable
> initialization and form events in version 16.
>
>
>
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Changes to variable initialization in v16?

2018-08-01 Thread Noah via 4D_Tech
Thank you both for the speedy replies!
Unfortunately this inherited application IS running in interpreted mode and
has hundreds of errors that would keep it from compiling.

As time permits we will occasionally revisit the compilation errors and
work towards a compiled version (but we have not made it there yet).
Consequently, Typing Generation and Syntax Checking both fail (since this
application had never been written with compilation as a goal)

Do you have any other suggestions?

Is is really 'that bad' to run in interpreted mode?
My original question was simply about the scoping of variable
initialization and form events in version 16.

On Tue, Jul 31, 2018 at 3:25 PM Timothy Penner via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> In addition to what has already been said -
>
> Using a compilation path of "All variables are typed" is highly
> recommended:
> http://kb.4d.com/assetid=50223
>
> -Tim
>
>
>
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Changes to variable initialization in v16?

2018-07-31 Thread Noah via 4D_Tech
Good afternoon,
We are in the process of converting an application from 15 to 16 and one of
the first errors that we have encountered came from a line that was setting
the query destination into a variable.

The variable was declared in the on Load form event, and this code has
worked without a problem for many versions back.

I was able to quickly bypass the runtime error by moving the variable
declaration out of the conditional block which only ran once (when the form
loaded) into the form method itself (not wrapped in a conditional). Rather
than blindly make a change, we would like to have a solid understanding of
what changed from 15 to 16.

I have combed over the changes listed here:
http://doc.4d.com/4Dv16/4D/16.3/Conversion-to-4D-v16.100-3673248.en.html
specifically:
http://doc.4d.com/4Dv16/4D/16.3/Changes-in-behavior.200-3673250.en.html

Has anyone else experienced this change in behavior?
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Server Monitoring...

2018-07-19 Thread Noah via 4D_Tech
We like to make use of command line tools, and this one was perfect!
https://github.com/miyako/4d-utility-ls4d

On Wed, Jul 18, 2018 at 1:11 AM fpoeck via 4D_Tech <4d_tech@lists.4d.com>
wrote:

> Using Nagios here as well internally.
>
> Services:
> - ping for the obvious
> - 4d using:
>
> https://exchange.nagios.org/directory/Plugins/Databases/4D/4D-Server/details
>
>
>
>
>
> --
> Sent from: http://4d.1045681.n5.nabble.com/4D-Tech-f1376241.html
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: problems with SEND RECORD

2018-07-03 Thread Noah via 4D_Tech
Many thanks, that was a silly oversight, explicitly saving to and moving to
the next record in the Approvals table fixes the problem.
I appreciate the suggestions for more efficient code!

On Tue, Jul 3, 2018 at 3:52 PM npdennis  wrote:

>
>
>  // THIS DOESN'T work! it approves the records but does append to the log
>
>
>
> Try this loop instead, you need a save record in the loop, and since you
> are saving each you don’t need the apply to selection and first record… the
> loop below will take less execution time and only modify the records once:
>
>
>
> CONFIRM(Current user+": Are you sure you want to approve these"+\
> String($selectedCount)+"records?";"Approve";"Don't Approve")
>
> If (OK=1)
>   For ($i;1;$selectedCount)
> [Approvals]approved_by:=Current user+" (4D Client)"
> [Approvals]approved_date:=Current date(*)
> [Approvals]notes:=[Approvals]notes+Char(13)+txtApprovalNotes
> [Approvals]log:=[Approvals]log+"4D client ("+Current user+") approved
> this record on"+\
> String(Current time(*))+" "+\
> String(Current date(*);" | Short")+Char(13)
> [Approvals];[Approvals]approved:=True
>
>     SAVE RECORD([Approvals])
> NEXT RECORD([Approvals])
>   End for
> Else
>   ALERT("Operation canceled.")
> End if
>
>
>
>
>
>
>
> On Jul 3, 2018, at 4:00 PM, Noah via 4D_Tech <4d_tech@lists.4d.com> wrote:
>
> Thank you all for the quick feedback!
>
> The approvals table has all records with Approved defaulting to False.
> The problem was with not including Set Channel (which is not really what I
> wanted to be doing anyways). I must have taken a fork in the road (while
> reading the documentation this morning) which lead to a place I should not
> have been.
>
> First problem was that looping over records in selection was not limiting
> it to one record inside the loop.
>
> http://doc.4d.com/4Dv15/4D/15.6/Records-in-selection.301-3817584.en.html
>
> When I tried an alternate approach, I ended up looking at sockets
>
> Here is a snippet from the original code that I was trying to get working:
>
> CONFIRM(Current user+": Are you sure you want to approve these
> "+String($selectedCount)+" records?";"Approve";"Don't Approve")
>
> If (OK=1)
> APPLY TO SELECTION([Approvals];[Approvals]approved:=True)
>
> FIRST RECORD([Approvals])
>
>  // THIS DOESN'T work! it approves the records but does append to the log
> of each record
> For ($i;1;$selectedCount)
>  [Approvals]approved_by:=Current user+" (4D Client)"
>  [Approvals]approved_date:=Current date(*)
>
>  $current_notes:=[Approvals]notes
>  [Approvals]notes:=$current_notes+Char(13)+txtApprovalNotes
>
>  $sTime_Stamp:=String(Current time(*))+" "+String(Current date(*);"|Short")
>  $new_line:="4D client ("+Current user+") approved this record on
> "+$sTime_Stamp+Char(13)
>  $current_log:=[Approvals]log
>  [Approvals]log:=$new_line+$current_log
>  NEXT RECORD
> End for
> Else
> ALERT("Operation canceled.")
> End if
>
>
> txtApprovalNotes is the name of a text entry field on the form.
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
>
>
>
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: problems with SEND RECORD

2018-07-03 Thread Noah via 4D_Tech
Thank you all for the quick feedback!

The approvals table has all records with Approved defaulting to False.
The problem was with not including Set Channel (which is not really what I
wanted to be doing anyways). I must have taken a fork in the road (while
reading the documentation this morning) which lead to a place I should not
have been.

First problem was that looping over records in selection was not limiting
it to one record inside the loop.

http://doc.4d.com/4Dv15/4D/15.6/Records-in-selection.301-3817584.en.html

When I tried an alternate approach, I ended up looking at sockets

Here is a snippet from the original code that I was trying to get working:

CONFIRM(Current user+": Are you sure you want to approve these
"+String($selectedCount)+" records?";"Approve";"Don't Approve")

If (OK=1)
APPLY TO SELECTION([Approvals];[Approvals]approved:=True)

FIRST RECORD([Approvals])

  // THIS DOESN'T work! it approves the records but does append to the log
of each record
For ($i;1;$selectedCount)
  [Approvals]approved_by:=Current user+" (4D Client)"
  [Approvals]approved_date:=Current date(*)

  $current_notes:=[Approvals]notes
  [Approvals]notes:=$current_notes+Char(13)+txtApprovalNotes

  $sTime_Stamp:=String(Current time(*))+" "+String(Current date(*);"|Short")
  $new_line:="4D client ("+Current user+") approved this record on
"+$sTime_Stamp+Char(13)
  $current_log:=[Approvals]log
  [Approvals]log:=$new_line+$current_log
  NEXT RECORD
End for
Else
ALERT("Operation canceled.")
End if


txtApprovalNotes is the name of a text entry field on the form.
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

problems with SEND RECORD

2018-07-03 Thread Noah via 4D_Tech
Good morning!
I work with a large codebase that has had many developers over the years.
Consequently, when building something new, I will sometimes look to see how
something was done previously. More often it has been the case that I will
go straight to the documentation to see the currently recommended 4D
approach to the issue.

Today I was looking at capturing the 'approval of selected records'.
Selected is a boolean value in the database. Stepping through the code I
could see that where we were supposed to be looping over the records in the
current selection, we were instead dealing with the whole selection.
Stepping back from the context of the application, I created a scratchpad
sort of method, which contains a simple query and a code snippet directly
from the documentation.

The 4th basic example in on this page:
http://doc.4d.com/4Dv15/4D/15.6/ForEnd-for.300-3818649.en.html produces an
-28 communication error after trying to SEND RECORD.


QUERY([Approvals];[Approvals]approved=False)


FIRST RECORD([Approvals])

For ($vlRecord;1;Records in selection([Approvals]))

  // Do something with the record

SEND RECORD([Approvals])

  // ...

  // Go to the next record

NEXT RECORD([Approvals])

End for


Am I missing something in my understanding of looping over records?
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

List form for reporting

2018-05-02 Thread Noah via 4D_Tech
Good afternoon!
I need to develop a print report that I was hoping would be a as simple as
PRINT SELECTION, however what needs to be printed is not in a single table
(there are at least two tables to get the information from).

The tables are called [Projects] and [Approvals]

One project can have many approvals and each approval is tied to an
account/fund (which is a non-unique attribute of the project). The projects
have a unique key but that key is not present in the approvals table. The
approvals records can be used to look up the associated project based on
certain query-able fields (project name and status).

I was thinking that this might be accomplished with multiple breaks as
shown in the documentation:
http://doc.4d.com/4Dv15/4D/15.6/An-example-report.300-3836729.en.html

However, I don't have a ton of experience with list forms (aside from the
last 3 days of investigations). I have gone through much of the
documentation and experimenting with form creation, but have not been able
to come up with a solution that I am happy with.

It would be nice to  develop a print form with the project information at
the top of the page and the related approval records listed below (on as
many pages as needed).

Something like that is shown in this video but they use the form wizard to
achieve this:
http://doc.4d.com/4Dv16/4D/16/Printing-forms.200-3246861.en.html

Can anyone provide some guidance on how I might be able to solve this
problem?

Many thanks in advance,
Noah
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**