cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Unable to update WTVariance

adev-2
4-Participant

Unable to update WTVariance

Hi,

I am trying to update the WTVariance object IBA but can't see the updated values can any one help me how I can do this using code

I am using this code right now

try{

            wt.change2.WTVariance var = (wt.change2.WTVariance)primaryBusinessObject;

            com.ptc.core.lwc.server.LWCNormalizedObject obj = new com.ptc.core.lwc.server.LWCNormalizedObject(var , null,java.util.Locale.US, null);

            obj.load(att);

            obj.set(att,attValue);

            obj.apply();

            //PersistenceHelper.manager.refresh(var );

            PersistenceHelper.manager.refresh(var );

            }

            catch (wt.util.WTException e) {

                            e.printStackTrace();

            }

2 REPLIES 2

HI @A D,

Please refer below code snippet for your reference.

Note: This example code is just for your reference. Kindly verify it on test server first.

public class UpdateWTVariance implements RemoteAccess {

  /**

  * @param args

  * @throws InvocationTargetException

  * @throws RemoteException

  */

  public static void main(String[] args) throws RemoteException, InvocationTargetException {

  RemoteMethodServer rms = RemoteMethodServer.getDefault();

  rms.setUserName("wcadmin");

  rms.setPassword("ts");

  rms.invoke("updateVarianceIBA", ext.UpdateWTVariance.class.getName(), null, null, null);

  }

  public static void updateVarianceIBA() throws WTException {

  ObjectIdentifier oid = ObjectIdentifier.newObjectIdentifier("wt.change2.WTVariance:2336782");

  WTVariance var = (WTVariance) PersistenceHelper.manager.refresh(oid);

  System.out.println("Variance Name: " + var.getName());

  PersistableAdapter theIBAs = new PersistableAdapter(var, null, java.util.Locale.US, new UpdateOperationIdentifier());

  theIBAs.load("savedAmount");

  theIBAs.set("savedAmount","14562");

  theIBAs.apply();

     // Persisting IBA Value

     PersistenceHelper.manager.modify(var);

     System.out.println(" *** Update Success *** ");

  }

}

I hope this helps you.

Regards,

Shirish

Hi Shirish,


Thank you so much for your help yes it worked for me

sorry for late reply

Announcements

Top Tags