Javascript conditions only on new record

Hello Developers,
I want to write some conditions only when new lead create. Not on update record in Javascript.
The problem is when I write custom js it will run on both new create and edit record, bcoz new record and edit record view are same.

If you using any logic hook , you may use this condition

if(!$bean->fetched_row){

// do something…
}

1 Like

Hello Ashish,
Thanks for your reply,
I solve this problem. I know we can check in logic hook. But my problem was I need to right custom js based on create or edit record.
So I did below code in viwe.edit.php which is extends from base module.

// View.edit.php
$user_id = $this->bean->id;
if($user_id){
$this->ss->assign(‘user_id’,$user_id);
}

// After assign value I have add hidden field in metadata editviewdef.php file
‘hidden’ =>
array(
0 => ‘’,
),

and then it will be availble in custom js.

Once again thank for reply. :slight_smile: