This topic is locked
[SOLVED]

 update field value on if...

11/25/2018 11:37:23 AM
PHPRunner General questions
I
itmann author

Hi,

i am a new pie and need little help with this.

I have a table for Meetings. Here is the structure:
-Meeting-ID

-Meeting-Name

-Meeting-Date

-Meeting-Time

-changed (options "Yes", "No" the default value is "No")
I need to put an event on the edit page which updates the field (changed) automaticaly to "yes" if the Meeting-Date or the Meeting-Time was changed.
I'd appreciate any help

admin 11/26/2018

In BeforeEdit event you have access to both old a new values so your code should be along the lines of

if ($values["Meeting-Date"]!=$oldvalues["Meeting-Date"] ||

$values["Meeting-Time"]!=$oldvalues["Meeting-Time"]) {

$values["changed"]="Yes";

}


More info:

https://xlinesoft.com/phprunner/docs/before_record_updated.htm

I
itmann author 11/27/2018

Hello,
thank you very much for you help.

i tested your solution today. now when i open the record for editing and click on save without changing anything it always updates the value of the field "changed" to yes!!
this is not meant to work this way <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=86402&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
so. what's wrong

admin 11/27/2018

I'm afraid you are doing something wrong. I'm not seeing anything in this code that wold trigger this kind of behaviour.

A
asawyer13DevClub member 11/27/2018



Hello,
thank you very much for you help.

i tested your solution today. now when i open the record for editing and click on save without changing anything it always updates the value of the field "changed" to yes!!
this is not meant to work this way <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=86415&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
so. what's wrong


Can you put your actual code here so we can see what the issue might be?

I
itmann author 11/29/2018

i resolved the problem in a different way and it works great:
in Edit page (Javascript on Load) i added this:

var ctrlMeeting-Date = Runner.getControl(pageid, 'Meeting-Date');

var ctrlMeeting-Time = Runner.getControl(pageid, 'Meeting-Time');

var ctrlChanged = Runner.getControl(pageid, 'Changed');

var X="Yes";
function func() {
ctrlChanged.setValue(X);
};
ctrlMeeting-Date.on('change', func);

ctrlMeeting-Time.on('change', func);


enjoy!!