Custom Objects Script - How to load the current y_table ID

lock
push_pin
done
Beantwoord
1

When I use the below script as a trigger "after saving custom object" how do I call the current open custom object record.
I have tried SearchEngine, GetCurrent, EventData URL, ExtraTable Getvalue "ID", GetInputvalue and loads more but just cant find any working sample!
How to you call current open Custom Object Record and Current Company Card from a Button Script & Trigger.
My Script code is below the screenshots.
Any help would be greatly apreciated, I have a Test Environment setup and I believe if the client sees this working they will Migrate to online :-)
 
 
 
 
 
 
____
//Script I'm Using
 
#setLanguageLevel 4;
//Things TeamProject do to the Custom Objects Table
ExtraTable e = getExtraTable("y_membership_db");
 
//  Load the record custom object no ID 82
Bool ok = e.load(82);
 
  // Convert values to numbers correctly
  Integer suma = e.getValue("x_direct_debit_amount").toInteger();
  Integer sumb = e.getValue("x_arrears").toInteger();
  Integer total = suma + sumb;
 
  print(" - Old DD Amount = " + suma.toString());
  print(" - Current Arrears = " + sumb.toString());
  print(" - Calculated Total =  " + total.toString());
 
  //  Save new total which is the VFI DD + arrears value
  e.setValue("x_direct_debit_amount", total.toString());
  e.setValue("x_membership_category", "Member");
  e.save();
// When testing as a Screen Designer Button show this results
  print(" - New DD Amount = " + e.getValue("x_direct_debit_amount"));
  print(" - Company Link = " + e.getValue("x_pub_card_link"));
  print(" - Member Contract ID = " + e.getValue("id"));
  print(" - Membership Contract Status = " + e.getValue("x_membership_category"));
 
// Use the link in custom objects to connect to company card using the contact_id
Integer companyId = e.getValue("x_pub_card_link").toInteger();
 
Company c;
c.load(companyId);
// When testing as a Screen Designer Button show this results
  print(" - Old Membership Status = " + c.getValue("contactCategory"));
 
  // Set the company card to Catergory = "Member" (category id 8)
  c.setValue("contactCategory", "8");
  c.save();
// When testing as a Screen Designer Button show this results
  print(" - Updated Membership Status To Member = " + c.getValue("contactCategory"));
 
//This lists all the Custom Object fields - - -
  // EventData ed = getEventData();
// ed.setNavigateTo("soprotocol:Cust32009/default.aspx?y_membership_db.main.minipreview&y_membership_db_id=74");
 
// SearchEngine se;
// se.addFields("extra_fields", "id,name,field_name,domain,extra_table");
// print(se.executeTextTable());
 
 

10 u, 0 m geleden | 11:34 p.m.

Alles Antwoorden (1)

Hi Davind, 

From your given example you need to change

from

ExtraTable e = getExtraTable("y_membership_db");
//  Load the record custom object no ID 82
Bool ok = e.load(82);
to

EventData ed = getEventData();
Integer currentId = ed.getInputValue("CustomObjectEntity.CustomObjectId").toInteger();

ExtraTable e = getExtraTable("y_membership_db");
Bool ok = e.load(currentId);

 

 

Let me know if that helped. 

 

1 u, 46 m geleden | 07:47 a.m.

Reply toevoegen