Skip to main content
Solved

Updating custom field via script


MWitczak
Hero (Customer)
Forum|alt.badge.img+10

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.

Best answer by anmise

MWitczak wrote:
anmise wrote:
MWitczak wrote:

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.

1DECLARE
2 -- p0 -> __lsResult
3 p0_ VARCHAR2(32000) := NULL;
4
5 -- p1 -> __sObjid
6 p1_ VARCHAR2(32000) := 'AAB2i+AAFAAAYZMAAA';
7
8
9 p2_ VARCHAR2(32000);
10
11 -- p3 -> __lsAttr
12 p3_ VARCHAR2(32000) := '';
13
14 -- p4 -> __sAction
15 p4_ VARCHAR2(32000) := 'DO';
16
17cursor get is
18select objkey from ABC_CLASS where abc_class='C';
19
20BEGIN
21for rec_ in get loop
22
23CLIENT_SYS.ADD_TO_ATTR('CF$_TEST_REF', rec_.objkey, p2_);
24IFSAPP.INVENTORY_PART_CFP.Cf_Modify__(p0_ , p1_ , p2_ , p3_ , p4_ );
25end loop;
26
27END;
28

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.

View original
Did this topic help you find an answer to your question?

4 replies

  • Superhero (Employee)
  • 1487 replies
  • May 7, 2020
MWitczak wrote:

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. 


MWitczak
Hero (Customer)
Forum|alt.badge.img+10
  • Author
  • Hero (Customer)
  • 68 replies
  • May 7, 2020
anmise wrote:
MWitczak wrote:

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.


  • Superhero (Employee)
  • 1487 replies
  • Answer
  • May 7, 2020
MWitczak wrote:
anmise wrote:
MWitczak wrote:

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.

1DECLARE
2 -- p0 -> __lsResult
3 p0_ VARCHAR2(32000) := NULL;
4
5 -- p1 -> __sObjid
6 p1_ VARCHAR2(32000) := 'AAB2i+AAFAAAYZMAAA';
7
8
9 p2_ VARCHAR2(32000);
10
11 -- p3 -> __lsAttr
12 p3_ VARCHAR2(32000) := '';
13
14 -- p4 -> __sAction
15 p4_ VARCHAR2(32000) := 'DO';
16
17cursor get is
18select objkey from ABC_CLASS where abc_class='C';
19
20BEGIN
21for rec_ in get loop
22
23CLIENT_SYS.ADD_TO_ATTR('CF$_TEST_REF', rec_.objkey, p2_);
24IFSAPP.INVENTORY_PART_CFP.Cf_Modify__(p0_ , p1_ , p2_ , p3_ , p4_ );
25end loop;
26
27END;
28

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.


MWitczak
Hero (Customer)
Forum|alt.badge.img+10
  • Author
  • Hero (Customer)
  • 68 replies
  • May 8, 2020

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings