Typecast not working

Certified Senior Developer

Hello Everyone,

I am using text() or any  function in type!{urn:com:appian:types}Test'(). But it seems not working. Can anyone suggest how I can do this?

Thanks

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    After changing datatype from Decimal to Varchar - It worked. However, still wondering if this is good way of returning decimal value with Varchar instead of Decimal. Really appreciate your feedback how better this could handle and where potentially the issue lies. 

  • 0
    Certified Lead Developer
    in reply to manjit.1486

    I personally wouldn't recommend storing the amount as a varchar. Probably best to find the root cause of this issue.

  • 0
    Certified Senior Developer
    in reply to Mathieu Drouin

    This is what I am asking. What should I do? Please see below code I am using to achieve.

      a!forEach(
        items: ri!empdetails,
        expression: 
          'type!{urn:com:appian:types:TPR}TPR_TEST'(
            name: fv!item.name,
            joinDate: fv!item.date,
            quantity: if(
              rule!GLB_isBlank(
                index(fv!item, "amount", {})
              ),
              {},
              fn!text(
                fixed(
                  abs(
                    sum(
                        index(fv!item, "amount", {}),
                    )
                  ),
                  2,             
                ),
                "00.00"
              )
            ),
            account: fv!item.account,
          )
      )

    As I said, I have changed datatype from Decimal to Varchar for quantity field. 

    It would be appreciated If I get assistance on this.

  • 0
    Certified Lead Developer
    in reply to manjit.1486

    Please post the xsd for the data type. Also curious to know what type ri!empDetails is.

  • 0
    Certified Senior Developer
    in reply to Mathieu Drouin

    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="urn:com:appian:types:TPR" targetNamespace="urn:com:appian:types:TPR">
      <xsd:complexType name="TPR_TEST">
        <xsd:annotation>
          <xsd:appinfo source="appian.jpa">@Table(name="TPR_TEST")</xsd:appinfo>
          <xsd:documentation><![CDATA[This data type refers to test data]]></xsd:documentation>
        </xsd:annotation>
        <xsd:sequence>
          <xsd:element name="id" nillable="true" type="xsd:int">
            <xsd:annotation>
              <xsd:appinfo source="appian.jpa">@Id @GeneratedValue @Column(name="id", nullable=false, unique=true, columnDefinition="INT")</xsd:appinfo>
            </xsd:annotation>
          </xsd:element>
          <xsd:element name="name" nillable="true" type="xsd:string">
            <xsd:annotation>
              <xsd:appinfo source="appian.jpa">@Column(name="Name", columnDefinition="VARCHAR(41)")</xsd:appinfo>
            </xsd:annotation>
          </xsd:element>
          <xsd:element name="joinDate" nillable="true" type="xsd:string">
            <xsd:annotation>
              <xsd:appinfo source="appian.jpa">@Column(name="JoinDate", columnDefinition="VARCHAR(10)")</xsd:appinfo>
            </xsd:annotation>
          </xsd:element>
         
          <xsd:element name="quantity" nillable="true" type="xsd:string">
            <xsd:annotation>
              <xsd:appinfo source="appian.jpa">@Column(name="Quantity", columnDefinition="VARCHAR(600)")</xsd:appinfo>
            </xsd:annotation>
          </xsd:element>
          <xsd:element name="account" nillable="true" type="xsd:string">
            <xsd:annotation>
              <xsd:appinfo source="appian.jpa">@Column(name="Account", columnDefinition="VARCHAR(80)")</xsd:appinfo>
            </xsd:annotation>
          </xsd:element>
        </xsd:sequence>
      </xsd:complexType>
    </xsd:schema>

    Please check the attached file. Actually I tried uploading xsd file but it seems not supported xsd extension - therefore, I converted it to normal text file and upload the same.

Reply
  • 0
    Certified Senior Developer
    in reply to Mathieu Drouin

    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="urn:com:appian:types:TPR" targetNamespace="urn:com:appian:types:TPR">
      <xsd:complexType name="TPR_TEST">
        <xsd:annotation>
          <xsd:appinfo source="appian.jpa">@Table(name="TPR_TEST")</xsd:appinfo>
          <xsd:documentation><![CDATA[This data type refers to test data]]></xsd:documentation>
        </xsd:annotation>
        <xsd:sequence>
          <xsd:element name="id" nillable="true" type="xsd:int">
            <xsd:annotation>
              <xsd:appinfo source="appian.jpa">@Id @GeneratedValue @Column(name="id", nullable=false, unique=true, columnDefinition="INT")</xsd:appinfo>
            </xsd:annotation>
          </xsd:element>
          <xsd:element name="name" nillable="true" type="xsd:string">
            <xsd:annotation>
              <xsd:appinfo source="appian.jpa">@Column(name="Name", columnDefinition="VARCHAR(41)")</xsd:appinfo>
            </xsd:annotation>
          </xsd:element>
          <xsd:element name="joinDate" nillable="true" type="xsd:string">
            <xsd:annotation>
              <xsd:appinfo source="appian.jpa">@Column(name="JoinDate", columnDefinition="VARCHAR(10)")</xsd:appinfo>
            </xsd:annotation>
          </xsd:element>
         
          <xsd:element name="quantity" nillable="true" type="xsd:string">
            <xsd:annotation>
              <xsd:appinfo source="appian.jpa">@Column(name="Quantity", columnDefinition="VARCHAR(600)")</xsd:appinfo>
            </xsd:annotation>
          </xsd:element>
          <xsd:element name="account" nillable="true" type="xsd:string">
            <xsd:annotation>
              <xsd:appinfo source="appian.jpa">@Column(name="Account", columnDefinition="VARCHAR(80)")</xsd:appinfo>
            </xsd:annotation>
          </xsd:element>
        </xsd:sequence>
      </xsd:complexType>
    </xsd:schema>

    Please check the attached file. Actually I tried uploading xsd file but it seems not supported xsd extension - therefore, I converted it to normal text file and upload the same.

Children