3 Replies Latest reply on Aug 10, 2015 8:30 AM by pthivierge

    update the attribute value using c# code


      how to update the attribute  value in pi system explorer  for the  current version of the existing element using c# code? Will anyone pls resolve it??

        • Re: update the attribute value using c# code
          Lonnie Bowling

          Hi Shifana,


          If I am understanding your question correctly, you want to use C# to change an attribute value. If so, you should look at the AF SDK. I put together a short introduction to getting started with the SDK, which is a good place to start:


          My New Getting Started with PI SDKs Blog Series


          From there you basically will want to use the SDK to retrieve the element, then update the attribute. How you update the attribute will depend on it's type, but it is not too complex.


          If your question is something different please let us know. If you get stuck, feel free to post more questions or do searches here on PI Square, there is a ton of information. 99% of the issues people have are most likely already answered here!


          Good Luck!



          1 of 1 people found this helpful
          • Re: update the attribute value using c# code

            Hello Shifana,


            We are always happy to help on our forums and thanks for participating.


            Please allow me the following remark, and be certain that this is done in a very friendly mindset:

            Even though there are a lot of skillful people ready to help there is a minimal effort that is required to get the best out of other community members.

            Please try to search the forum and documentation with your question first.  Then if required, please post your question (You should post only once!, I can see you have another very similar question here).  Also make sure to put enough details in your question so others can understand and guide you.  This is the fastest route to get a quality answer.  Also after you have found what you are looking for, please let us know by replying back on the discussion you have started.



            Back to your question:


            To change an attribute value,

            • First you need to find the element you need, you can do this by using either FindElement or FindElements methods, there are many and you should be able to find the one you need here: AFElement Methods.
            • Then you need get the attribute(s) you want to change (you can use the Attributes Property (or in you have a lot of elements, you should look at AFElement.LoadAttributes Method to make partial loading).
            • Once you have the attributes, you need to use the SetValue method to change the attribute value. AFAttribute.SetValue Method (AFValue) .  You should read the remarks carefully on this one.
            • Finally, once your change is done, you need to do a CheckIn on the Element that contains the attribute. AFElement.CheckIn Method .  Remarks on the Checking Method are also worth to read.


            Hope this helps and please let us know in case you have more questions and let us know how you are progressing.

            1 of 1 people found this helpful