Topic
  • 4 replies
  • Latest Post - ‏2013-10-28T14:20:46Z by Kareem Naguib
Kareem Naguib
Kareem Naguib
65 Posts

Pinned topic Automation Script doesn't save values to DB

‏2013-10-28T11:15:44Z |

Hello Professionals, 

 

i started to play with Maximo Automation Script 7.5, i want to get value from field and set it to another field in the same object,

i created an object launch point with simple code, and it is working fine, all values copied from first field to the other one,

but, the value is not saved in the database,

how can i save it to database?

Thanks in Advance

Updated on 2013-10-28T12:20:09Z at 2013-10-28T12:20:09Z by Kareem Naguib
  • SASHULL
    SASHULL
    305 Posts
    ACCEPTED ANSWER

    Re: Automation Script doesn't save values to DB

    ‏2013-10-28T13:16:43Z  

    for more explanation, i found that script doesn't save in database, it only copy data from field to the other,

    and even if i pressed the save button in the application, value doesn't save too,

    but, if i change any value in any other field in the application and press the save button, the new value copied by the automation script saved to database,

     

    Can i make this step from code in the automation script?

    Kareem,

    You are correct that an Automation Script doesn't cause a SAVE event directly. You can have an Object Launch point that's being called during a SAVE event (Add/Update/Delete Launch points all happen when the user clicks the SAVE button) and you can call a save explicitly from an Automation Script, though it isn't typically recommended.

    The reason I don't recommend it is what if the user made a mistake and wants to discard their changes? If you force a save then that user has no option to back out of the changes. The only time I can think I have ever called the save() method on a set is during ACTION Launch Point automation scripts called by an Escalation. These by their very nature (being called on a schedule without user intervention) require that we call a SAVE if we want those values to persist.

    What you are trying to do should work, but perhaps it's due to you trying to do it on Initialize event? (I'm making the assumption since you said it's Object launch points and it sounds like it fires before a user ever saves, thus it has to be on Initialize). Personally, if I'm doing something without any user input required and I need a value to be stored persistently I do it through an Escalation calling an Automation Script. This way I'm a) not dependent on the user pulling up the record and b) not firing every time something is initialized (knowing that initialize happens even for records on the list tab). It won't always be perfect but if you have it on a frequent schedule (5-10 minutes) it should be pretty reliable unless the data changes more frequently.

    To test my theory that is because you have it on initialize, try to move it to the Add/Update (or just Update) event and see if it stores it in the database. My guess would be that it would. If that is the case then I would probably move it to an Action launch point (your script most likely wouldn't even need to change, you would just have to create a new launch point and create an escalation to call it from).

  • Kareem Naguib
    Kareem Naguib
    65 Posts

    Re: Automation Script doesn't save values to DB

    ‏2013-10-28T12:31:26Z  

    for more explanation, i found that script doesn't save in database, it only copy data from field to the other,

    and even if i pressed the save button in the application, value doesn't save too,

    but, if i change any value in any other field in the application and press the save button, the new value copied by the automation script saved to database,

     

    Can i make this step from code in the automation script?

  • SASHULL
    SASHULL
    305 Posts

    Re: Automation Script doesn't save values to DB

    ‏2013-10-28T13:16:43Z  

    for more explanation, i found that script doesn't save in database, it only copy data from field to the other,

    and even if i pressed the save button in the application, value doesn't save too,

    but, if i change any value in any other field in the application and press the save button, the new value copied by the automation script saved to database,

     

    Can i make this step from code in the automation script?

    Kareem,

    You are correct that an Automation Script doesn't cause a SAVE event directly. You can have an Object Launch point that's being called during a SAVE event (Add/Update/Delete Launch points all happen when the user clicks the SAVE button) and you can call a save explicitly from an Automation Script, though it isn't typically recommended.

    The reason I don't recommend it is what if the user made a mistake and wants to discard their changes? If you force a save then that user has no option to back out of the changes. The only time I can think I have ever called the save() method on a set is during ACTION Launch Point automation scripts called by an Escalation. These by their very nature (being called on a schedule without user intervention) require that we call a SAVE if we want those values to persist.

    What you are trying to do should work, but perhaps it's due to you trying to do it on Initialize event? (I'm making the assumption since you said it's Object launch points and it sounds like it fires before a user ever saves, thus it has to be on Initialize). Personally, if I'm doing something without any user input required and I need a value to be stored persistently I do it through an Escalation calling an Automation Script. This way I'm a) not dependent on the user pulling up the record and b) not firing every time something is initialized (knowing that initialize happens even for records on the list tab). It won't always be perfect but if you have it on a frequent schedule (5-10 minutes) it should be pretty reliable unless the data changes more frequently.

    To test my theory that is because you have it on initialize, try to move it to the Add/Update (or just Update) event and see if it stores it in the database. My guess would be that it would. If that is the case then I would probably move it to an Action launch point (your script most likely wouldn't even need to change, you would just have to create a new launch point and create an escalation to call it from).

  • bgbaird
    bgbaird
    259 Posts

    Re: Automation Script doesn't save values to DB

    ‏2013-10-28T13:30:52Z  

    Kareem, I'm not sure of your requirement, but I'm attaching demo based on an attribute launch point.

    In WOTRACK, when the user populates assetnum and tabs out, the description is replaced with the assetnum concatenated with the existing description.

    The new description is just part of the open object until the record is saved.

    Remember, this is just an example.

     

    Brian

     

     

     

    Updated on 2013-10-28T13:31:50Z at 2013-10-28T13:31:50Z by bgbaird
  • Kareem Naguib
    Kareem Naguib
    65 Posts

    Re: Automation Script doesn't save values to DB

    ‏2013-10-28T14:20:46Z  
    • bgbaird
    • ‏2013-10-28T13:30:52Z

    Kareem, I'm not sure of your requirement, but I'm attaching demo based on an attribute launch point.

    In WOTRACK, when the user populates assetnum and tabs out, the description is replaced with the assetnum concatenated with the existing description.

    The new description is just part of the open object until the record is saved.

    Remember, this is just an example.

     

    Brian

     

     

     

    Thank you brian for this helpful sample