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 Reply
  • 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.

Children
  • 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.

  • 0
    Certified Lead Developer
    in reply to manjit.1486

    1. In this xsd, quantity is set to varchar(600).

    2. Also didn't mention what type the rule input was (empDetails).

  • 0
    Certified Senior Developer
    in reply to Mathieu Drouin

    1. Yes. But, I have changed this to varchar(50).

    2. empDetails (List of TPR_TEST (urn:com:appian:types:TPR))