Updating custom field via script | IFS Community
Solved

Updating custom field via script


Userlevel 3
Badge +7

Hello,

 

I’ve been trying to use PL/SQL scripts to update some custom fields in IFS 10.  I used the following:

 

(code snippet)

      VC_INFO_      := NULL;
      VC_OBJID_     := V_OBJID_;  -- obtained via cursor
      VC_ATTR_CF_   := 'CF$_CF_CUSTOMER' || CHR(31) || 'C101040' || CHR(30);
      VC_ATTR_      := '';
      VC_ACTION_    := 'DO';

       ifsapp.INVENTORY_PART_CFP.Cf_Modify__ (  
         INFO_       => VC_INFO_
        ,OBJID_      => VC_OBJID_
        ,ATTR_CF_    => VC_ATTR_CF_
        ,ATTR_       => VC_ATTR_
        ,ACTION_     => VC_ACTION_
      ) ;      

 

 

This worked on a standard free entry field, but does not work on a referenced field.  Is there any way to do this via script, or will this require a different method to update?  Any thoughts are appreciated.

icon

Best answer by anmise 7 May 2020, 22:50

View original

4 replies

Userlevel 7

Hello,

 

I’ve been trying to use PL/SQL scripts to update some custom fields in IFS 10.  I used the following:

 

(code snippet)

      VC_INFO_      := NULL;
      VC_OBJID_     := V_OBJID_;  -- obtained via cursor
      VC_ATTR_CF_   := 'CF$_CF_CUSTOMER' || CHR(31) || 'C101040' || CHR(30);
      VC_ATTR_      := '';
      VC_ACTION_    := 'DO';

       ifsapp.INVENTORY_PART_CFP.Cf_Modify__ (  
         INFO_       => VC_INFO_
        ,OBJID_      => VC_OBJID_
        ,ATTR_CF_    => VC_ATTR_CF_
        ,ATTR_       => VC_ATTR_
        ,ACTION_     => VC_ACTION_
      ) ;      

 

 

This worked on a standard free entry field, but does not work on a referenced field.  Is there any way to do this via script, or will this require a different method to update?  Any thoughts are appreciated.

If it’s a reference field you’d have to update the source and not the custom field. 

Userlevel 3
Badge +7

Hello,

 

I’ve been trying to use PL/SQL scripts to update some custom fields in IFS 10.  I used the following:

 

(code snippet)

      VC_INFO_      := NULL;
      VC_OBJID_     := V_OBJID_;  -- obtained via cursor
      VC_ATTR_CF_   := 'CF$_CF_CUSTOMER' || CHR(31) || 'C101040' || CHR(30);
      VC_ATTR_      := '';
      VC_ACTION_    := 'DO';

       ifsapp.INVENTORY_PART_CFP.Cf_Modify__ (  
         INFO_       => VC_INFO_
        ,OBJID_      => VC_OBJID_
        ,ATTR_CF_    => VC_ATTR_CF_
        ,ATTR_       => VC_ATTR_
        ,ACTION_     => VC_ACTION_
      ) ;      

 

 

This worked on a standard free entry field, but does not work on a referenced field.  Is there any way to do this via script, or will this require a different method to update?  Any thoughts are appreciated.

If it’s a reference field you’d have to update the source and not the custom field. 

 

When you say update the source, I’m not quite certain what that means?  Forgive me, as I am somewhat new to these custom objects.

 

The persistent custom reference field is attached to the inventory_part and the LU reference is CustOrdCustomer.  The company wants to associate inventory parts to certain customers, so the CF_CUSTOMER field was added to the Inventory Part logical unit.  I’m fetching the OBJID for that particular inventory part via cursor and then attempting to associate the particular customer to that inventory part. 

 

Thank you for taking the time to respond.

Userlevel 7

Hello,

 

I’ve been trying to use PL/SQL scripts to update some custom fields in IFS 10.  I used the following:

 

(code snippet)

      VC_INFO_      := NULL;
      VC_OBJID_     := V_OBJID_;  -- obtained via cursor
      VC_ATTR_CF_   := 'CF$_CF_CUSTOMER' || CHR(31) || 'C101040' || CHR(30);
      VC_ATTR_      := '';
      VC_ACTION_    := 'DO';

       ifsapp.INVENTORY_PART_CFP.Cf_Modify__ (  
         INFO_       => VC_INFO_
        ,OBJID_      => VC_OBJID_
        ,ATTR_CF_    => VC_ATTR_CF_
        ,ATTR_       => VC_ATTR_
        ,ACTION_     => VC_ACTION_
      ) ;      

 

 

This worked on a standard free entry field, but does not work on a referenced field.  Is there any way to do this via script, or will this require a different method to update?  Any thoughts are appreciated.

If it’s a reference field you’d have to update the source and not the custom field. 

 

When you say update the source, I’m not quite certain what that means?  Forgive me, as I am somewhat new to these custom objects.

 

The persistent custom reference field is attached to the inventory_part and the LU reference is CustOrdCustomer.  The company wants to associate inventory parts to certain customers, so the CF_CUSTOMER field was added to the Inventory Part logical unit.  I’m fetching the OBJID for that particular inventory part via cursor and then attempting to associate the particular customer to that inventory part. 

 

Thank you for taking the time to respond.

I misunderstood, didn’t realise it was a persistent reference field. 

You will need to get the objkey from the source for the reference. 


In the quick example below (you’ll obviously have to get the objid for the object you want to update, p1_, but just an example) I’m getting OBJKEY from ABC_CLASS which is what my custom field is referencing.

DECLARE
-- p0 -> __lsResult
p0_ VARCHAR2(32000) := NULL;

-- p1 -> __sObjid
p1_ VARCHAR2(32000) := 'AAB2i+AAFAAAYZMAAA';


p2_ VARCHAR2(32000);

-- p3 -> __lsAttr
p3_ VARCHAR2(32000) := '';

-- p4 -> __sAction
p4_ VARCHAR2(32000) := 'DO';

cursor get is
select objkey from ABC_CLASS where abc_class='C';

BEGIN
for rec_ in get loop

CLIENT_SYS.ADD_TO_ATTR('CF$_TEST_REF', rec_.objkey, p2_);
IFSAPP.INVENTORY_PART_CFP.Cf_Modify__(p0_ , p1_ , p2_ , p3_ , p4_ );
end loop;

END;

When I run the above code it’ll update my field.

 

A quick tip is that you manually update your field with the debug console open (CTRL+SHIFT+D) and then copy the modify call from PL/SQL Details tab.

 

Let me know if you need further help or if this gives you enough to get by.

Userlevel 3
Badge +7

That worked like a charm.  I am so appreciative of your help!  I must have missed the objkey reference out of the debugger.  Thank you again for sharing your knowledge!

Reply